Check-in [84e714bd8c]

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add Tcl_GetWideIntFromObj() description of change.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:84e714bd8c6cb303e54def9889b4be799fa6067a2f95169742448e64c8a89a41
User & Date: jan.nijtmans 2018-08-24 12:18:52
Context
2018-08-26
14:50
CFV by DKF check-in: 4fc22720ff user: dkf tags: trunk
2018-08-24
12:18
Add Tcl_GetWideIntFromObj() description of change. check-in: 84e714bd8c user: jan.nijtmans tags: trunk
2018-08-23
15:22
Slight formatting, and adding a link to the related Sqlite change. check-in: cf60913448 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tip/514.md.

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
..
69
70
71
72
73
74
75
76
77
78



79
80
81
82
83
84
85
86
87
88
1
% string is wide 18446744073709551615
1
% string is wide 18446744073709551616
0
</pre>

So, valid wide integers appear to range from -2^64+1 to +2^64-1.  Most people learn in school that 64-bit integers range from -2^63 to 2^63-1. Are Tcl's wide integers 65-bit, but then excluding -18446744073709551616?


<pre>
% expr int(2147483648)          ; #on LP64/ILP64 platforms
2147483648
% expr int(2147483648)          ; #on other platforms
-2147483648
................................................................................
 * On all platforms, the int() math function is modified to do 64-bit truncation, as it already does on [LP64/ILP64](https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models) systems (e.g. 64-bit Linux).
   int() will thus become synonym for wide(). The wide() function will become deprecated in Tcl 9.0, but it will not be removed yet.

 * The ranges of "string is integer" and "string is wideinteger" are changed to match the range of the int()/wide() math function.
   So these functions will report true (1) if the number is in the range -9223372036854775808..9223372036854775807.
   The "string is wideinteger" command will be deprecated in Tcl 9.0, but it will not be removed yet.

 * The C function Tcl\_GetIntFromObj() is changed to return TCL\_OK if the Tcl_Obj contains values in the range of -2147483648..4294967295. So,
   it succeeds if the number fits in either a platform "int", either a platform "unsigned int" type.




 * The C function Tcl\_GetLongFromObj() is changed to behave like Tcl\_GetIntFromObj() if sizeof(long) == sizeof(ing), and to behave like Tcl\_GetWideIntFromObj() if sizeof(long) == sizeof(Tcl_WideInt)

# Implementation

Currently, the proposed implementation is available in the [all-wideint branch]
(https://core.tcl.tk/tcl/timeline?r=all-wideint). (WIP)

# Copyright

This document has been placed in the public domain.







|







 







|


>
>
>
|




|




42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
1
% string is wide 18446744073709551615
1
% string is wide 18446744073709551616
0
</pre>

So, valid wide integers appear to range from -(2^64-1) to +2^64-1.  Most people learn in school that 64-bit integers range from -2^63 to 2^63-1. Are Tcl's wide integers 65-bit, but then excluding -18446744073709551616?


<pre>
% expr int(2147483648)          ; #on LP64/ILP64 platforms
2147483648
% expr int(2147483648)          ; #on other platforms
-2147483648
................................................................................
 * On all platforms, the int() math function is modified to do 64-bit truncation, as it already does on [LP64/ILP64](https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models) systems (e.g. 64-bit Linux).
   int() will thus become synonym for wide(). The wide() function will become deprecated in Tcl 9.0, but it will not be removed yet.

 * The ranges of "string is integer" and "string is wideinteger" are changed to match the range of the int()/wide() math function.
   So these functions will report true (1) if the number is in the range -9223372036854775808..9223372036854775807.
   The "string is wideinteger" command will be deprecated in Tcl 9.0, but it will not be removed yet.

 * The C function Tcl\_GetIntFromObj() is changed to return TCL\_OK if the Tcl_Obj contains a value in the range of -2147483648..4294967295. So,
   it succeeds if the number fits in either a platform "int", either a platform "unsigned int" type.

 * The C function Tcl\_GetWideIntFromObj() is changed to return TCL\_OK if the Tcl_Obj contains a value in the range of -9223372036854775808..9223372036854775807.
   So, it succeeds if the number fits in a Tcl_WideInt.

 * The C function Tcl\_GetLongFromObj() is changed to behave like Tcl\_GetIntFromObj() if sizeof(long) == sizeof(int), and to behave like Tcl\_GetWideIntFromObj() if sizeof(long) == sizeof(Tcl_WideInt)

# Implementation

Currently, the proposed implementation is available in the [all-wideint branch]
(https://core.tcl.tk/tcl/timeline?r=all-wideint).

# Copyright

This document has been placed in the public domain.