Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006982 [Squeak] Kernel minor always 03-14-08 22:31 04-18-10 21:58
Reporter nicolas cellier View Status public  
Assigned To nicolas cellier
Priority normal Resolution fixed  
Status closed   Product Version 3.10
Summary 0006982: Number>>readFrom: does not handle many digits correctly
Description It incorrectly answer an Infinity or even a NaN in some cases:

| s1 s2 |
s1 := '0.' , (String new: 320 withAll: $0) , '1e321'.
s2 := '1' , (String new: 321 withAll: $0) , '.0e321'.
self assert: (Number readFrom: s1) = 1.
self assert: (Number readFrom: s2) = 1.
  "First is Infinity, second is NaN..."
self assert: (SqNumberParser readFrom: s1) = 1.
self assert: (SqNumberParser readFrom: s2) = 1.

It seems it would be time to connect SqNumberParser...
Beside, SqNumberParser answer nearest Float.
Additional Information
Attached Files  Float-readFromManyDigits-Test-M6982-nice.1.cs [^] (786 bytes) 03-15-08 00:06
 Float-readFromManyDigits-Patch-M6982-nice.1.cs [^] (6,067 bytes) 03-15-08 00:11
 Float-initialize-Patch-M6982-nice.1.cs [^] (1,570 bytes) 03-15-08 21:55
 Float-readFromManyDigits-Patch-M6982-nice.2.cs [^] (4,571 bytes) 08-31-08 00:33

- Relationships

- Notes
(0011922 - 362 - 416 - 416 - 416 - 416 - 416)
nicolas cellier
03-14-08 22:34

Hem, i'm just bad at copy/paste game... correct test is below:


| s1 s2 |
s1 := '1' , (String new: 321 withAll: $0) , '.0e-321'.
s2 := '0.' , (String new: 320 withAll: $0) , '1e321'.
self assert: (Number readFrom: s1) = 1.
self assert: (Number readFrom: s2) = 1.
self assert: (SqNumberParser parse: s1) = 1.
self assert: (SqNumberParser parse: s2) = 1.
 
(0011925 - 248 - 272 - 272 - 659 - 659 - 659)
nicolas cellier
03-15-08 00:16

Beware, the patch is not compatible with the old behaviour of answering 0 when there is no digit. It raise an Error instead.

Use (Number readFrom aStream ifFail: [0]) explicitely if interested in this feature.

See also 0003512 0006779 0006976 0003712
 
(0011928 - 325 - 419 - 419 - 419 - 419 - 419)
nicolas cellier
03-15-08 21:56

If Number readFrom: is modified to use SqNumberParser,
then the constant used to initialize MaxVal is too high,
and leads to an Infinity if recompiled.

So here comes patch Float-initialize-Patch-M6982-nice.1.cs
new and old values are respectively:

    MaxVal _ 1.7976931348623157e308.
    MaxVal _ 1.7976931348623159e308.
 
(0012163 - 271 - 331 - 331 - 331 - 331 - 331)
nicolas cellier
05-25-08 18:38

"fix begin"
Installer mantis bug: 6982 fix:'Float-readFromManyDigits-Patch-M6982-nice.1.cs'.
Installer mantis bug: 6982 fix:'Float-initialize-Patch-M6982-nice.1.cs'.
"fix test"
Installer mantis bug: 6982 fix:'Float-readFromManyDigits-Test-M6982-nice.1.cs'.
"fix end"
 
(0012543 - 308 - 386 - 386 - 386 - 386 - 386)
nicolas cellier
08-29-08 20:13
edited on: 08-31-08 00:33

"fix begin"
Installer mantis ensureFix: 7169.
Installer mantis bug: 6982 fix:'Float-readFromManyDigits-Patch-M6982-nice.1.cs'.
Installer mantis bug: 6982 fix:'Float-initialize-Patch-M6982-nice.2.cs'.
"fix test"
Installer mantis bug: 6982 fix:'Float-readFromManyDigits-Test-M6982-nice.1.cs'.
"fix end"

 
(0012554 - 261 - 349 - 349 - 349 - 349 - 349)
nicolas cellier
08-31-08 00:36

There was a stupid bug
    instVar = ...
instead of
    instVar := ...
in Float-readFromManyDigits-Patch-M6982-nice.1.cs

Rather use Float-readFromManyDigits-Patch-M6982-nice.2.cs instead.

He, the leftArrow would be welcome to avoid this kind of typo.
 
(0013509 - 114 - 120 - 430 - 430 - 430 - 430)
nicolas cellier
02-13-10 02:06

in http://source.squeak.org/trunk/Kernel-nice.396.mcz [^]
and http://source.squeak.org/trunk/KernelTests-nice.131.mcz [^]
 

- Issue History
Date Modified Username Field Change
03-14-08 22:31 nicolas cellier New Issue
03-14-08 22:34 nicolas cellier Note Added: 0011922
03-15-08 00:06 nicolas cellier File Added: Float-readFromManyDigits-Test-M6982-nice.1.cs
03-15-08 00:11 nicolas cellier File Added: Float-readFromManyDigits-Patch-M6982-nice.1.cs
03-15-08 00:16 nicolas cellier Note Added: 0011925
03-15-08 21:55 nicolas cellier File Added: Float-initialize-Patch-M6982-nice.1.cs
03-15-08 21:56 nicolas cellier Note Added: 0011928
05-25-08 18:38 nicolas cellier Note Added: 0012163
08-29-08 20:13 nicolas cellier Note Added: 0012543
08-31-08 00:33 nicolas cellier File Added: Float-readFromManyDigits-Patch-M6982-nice.2.cs
08-31-08 00:33 nicolas cellier Note Edited: 0012543
08-31-08 00:36 nicolas cellier Note Added: 0012554
01-10-09 02:13 Keith_Hodges Status new => pending
02-13-10 02:06 nicolas cellier Status pending => resolved
02-13-10 02:06 nicolas cellier Fixed in Version  => trunk
02-13-10 02:06 nicolas cellier Resolution open => fixed
02-13-10 02:06 nicolas cellier Assigned To  => nicolas cellier
02-13-10 02:06 nicolas cellier Note Added: 0013509
04-18-10 21:58 andreas Status resolved => closed


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
78 total queries executed.
48 unique queries executed.
Powered by Mantis Bugtracker