|
2006-05-04
| ||
| 19:56 | • Add attachment 1480509-85.patch to ticket [1480509fff] artifact: 18d79b88d7 user: dgp | |
| 19:56 | • Ticket [1480509fff] Allow srand() to handle big wides status still Closed wi... artifact: 8d675cfad6 user: dgp | |
| 19:56 | • Closed ticket [1480509fff]. artifact: 4d0905428c user: dgp | |
| 19:32 | • Ticket [1480509fff]: 4 changes artifact: 89d08d58ca user: dgp | |
| 19:32 | • Add attachment 1480509.patch to ticket [1480509fff] artifact: bcacee49a5 user: dgp | |
| 19:32 | • Ticket [1480509fff] Allow srand() to handle big wides status still Open with... artifact: b47f41ae9c user: dgp | |
|
2006-05-03
| ||
| 22:44 | • Ticket [1480509fff]: 1 change artifact: 019aae1b5c user: dgp | |
| 22:42 | • Ticket [1480509fff]: 7 changes artifact: 821b435395 user: dgp | |
| 22:31 | • Ticket [1480509fff]: 4 changes artifact: f714652969 user: dgp | |
| 22:29 | • Ticket [1480509fff]: 4 changes artifact: cdb6ac1b34 user: dgp | |
| 22:16 | • Ticket [1480509fff]: 4 changes artifact: f2f226b369 user: afredd | |
| 21:51 | • Ticket [1480509fff]: 4 changes artifact: 909de6a2fc user: dgp | |
| 21:46 | • Ticket [1480509fff]: 4 changes artifact: 69af35bdd4 user: dgp | |
| 21:44 | • Ticket [1480509fff]: 4 changes artifact: 570b634e5a user: afredd | |
| 20:49 | • Ticket [1480509fff]: 4 changes artifact: 19f7108602 user: dgp | |
| 04:00 | • Ticket [1480509fff]: 7 changes artifact: 5e8d438349 user: dkf | |
|
2006-05-02
| ||
| 16:13 | • New ticket [1480509fff]. artifact: a2bf60921e user: afredd | |
Allow srand() to handle big wides
Closed / Fixed1480509fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2006-05-02 16:13:46
Currently srand() takes an integer (long) argument.
It would be nice if it was extended to also handling
wides that were too big for a long aswell.
Rationale:
expr {srand( [clock clicks] )}
is probably not an uncomon idiom (well i use it :-)
This is fine in 8.4 where [clock clicks] is a long,
but under 8.5 gives the initially confusing error:
can't use floating-point value as argument to srand
Although rand()'s "randSeed" is a long, in the case
where it is given a big wide, couldn't Tcl just, for
example, truncate it down to a long?
dkfplain2006-05-03 04:00:23
Logged In: YES user_id=79902 Actually, Tcl automatically seeds the PRNG with a value based on [clock clicks] anyway, even without being asked. The real use for srand() is for getting a *reproducable* sequence of pseudorandom numbers...
dgpplain2006-05-03 20:49:28
Logged In: YES user_id=80530 Um, just a minor correction. Currently srand() takes an "int" argument, not a "long" argument. That is, only values that pass [string is integer -strict] are accepted.
afreddplain2006-05-03 21:44:08
Logged In: YES user_id=1386588 I'm happy with Donal's answer - my call to srand() was unnecesary. I'm happy to close this report now. >Currently srand() takes an "int" >argument, not a "long" argument. >That is, only values that pass >[string is integer -strict] are >accepted. ...i was skeptical when i read this (!) but, you're right: % info pa 8.5a3 % string is integer -strict 4294967296 0 % string is integer -strict 4294967295 1 % expr srand(4294967295) 0.7574217011022483 % expr srand(4294967296) can't use floating-point value as argument to srand although, this isn't the behaviour of 8.4: % info pa 8.4.8 % string is integer -strict 4294967295 1 % string is integer -strict 4294967296 0 % expr srand(4294967295) 0.757421701102 % expr srand(4294967296) 0.242578298898
dgpplain2006-05-03 21:46:17
Logged In: YES user_id=80530 Um, sorry, I take that correction back. ExprSrandFunc does indeed pull a "long" from the argument, and then truncates to "int". And this means there's no simple way to test an argument for acceptability at the script level.
dgpplain2006-05-03 21:51:59
Logged In: YES user_id=80530 Note that on 32-bit platforms, "long" and "int" are identical, so the distinction I made doesn't show up there. I'm troubled that my 8.4 results are different from yours: % info patch 8.4.13 % expr srand(4294967295) 0.757421701102 % expr srand(4294967296) can't use floating-point value as argument to srand
afreddplain2006-05-03 22:16:27
Logged In: YES user_id=1386588 fyi - my previous 8.4 result was from an ActiveState installed tclsh... Just tried with a self built version: % info pa 8.4.11 % expr srand(4294967296) can't use floating-point value as argument to srand And with an older self built (debug): % info pa 8.4.6 % expr srand(4294967296) 0.242578298898
dgpplain2006-05-03 22:29:30
Logged In: YES user_id=80530 Mystery solved: 2005-04-05 Don Porter <[email protected]> * generic/tclExecute.c (ExprSrandFunc): Replaced incursions into the * generic/tclUtil.c (TclGetIntForIndex): intreps of numeric types with simpler calls of Tcl_GetIntFromObj and Tcl_GetLongFromObj, now that those routines are better behaved wrt shimmering. [Patch 1177219]
dgpplain2006-05-03 22:31:17
Logged In: YES user_id=80530 Mystery solved: 2005-04-05 Don Porter <[email protected]> * generic/tclExecute.c (ExprSrandFunc): Replaced incursions into the * generic/tclUtil.c (TclGetIntForIndex): intreps of numeric types with simpler calls of Tcl_GetIntFromObj and Tcl_GetLongFromObj, now that those routines are better behaved wrt shimmering. [Patch 1177219]
dgpplain2006-05-03 22:42:25
data_type - 110894 Logged In: YES user_id=80530 Looks like that change caused this bug.
dgp Ticket [1480509fff]: 1 change
[History diff]2006-05-03 22:44:34
dgpplain2006-05-04 19:32:21
Logged In: YES user_id=80530 Here's a patch for 8.4.14
dgpplain2006-05-04 19:32:25
File Added - 176828: 1480509.patch
dgpplain2006-05-04 19:56:56
Logged In: YES user_id=80530 and the patch for 8.5a4. Both patches committed.
dgpplain2006-05-04 19:56:57
File Added - 176830: 1480509-85.patch
Log in (anonymous is fine) to add a comment.
Attachments:
- 1480509-85.patch [download] added by dgp on 2006-05-04 19:56:57. [details]
- 1480509.patch [download] added by dgp on 2006-05-04 19:32:24. [details]