BUG: Scientific Number to String/String to Number

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

BUG: Scientific Number to String/String to Number

Christopher J. Demers
The code bellow demonstrates a numeric conversion bug in Dolphin 4.1.3.
Actually the bug may be the string representation code of the number rather
than the string to number conversion code.  This code works in 4.1.2.

('3.0e-2' asNumber) printString asNumber

The problem is that the printString returns '3.e-002', but it needs the $0
after the $. to convert back to the number so it returns 3.

Chris


Reply | Threaded
Open this post in threaded view
|

Re: Scientific Number to String/String to Number

Blair McGlashan
Chris

You wrote in message news:9mjeu7$2eu8p$[hidden email]...
> The code bellow demonstrates a numeric conversion bug in Dolphin 4.1.3.
> Actually the bug may be the string representation code of the number
rather
> than the string to number conversion code.  This code works in 4.1.2.
>
> ('3.0e-2' asNumber) printString asNumber
>
> The problem is that the printString returns '3.e-002', but it needs the $0
> after the $. to convert back to the number so it returns 3.

Thanks for your bug report. It is in fact, as you suspected, due to an error
in the printing rather than the number parsing logic. It worked in 4.1.2
because the number parsing logic in that was "too lenient".

Ironically this and a number of previously fixed bugs with printing floating
point numbers have been caused by the decision to use the C runtime library
to format them (the idea being to avoid re-inventing the wheel - we don't
believe in doing everything in Smalltalk just for the sake of it). Anyway
I've had enough now and I'm going to implement it in Smalltalk for a future
release, but in the meantime I've attached a temporary patch.

Regards

Blair
























begin 666 349.st
M(B,S-#DB(0T*#0HA1FQO870@;65T:&]D<T9O<B$-"@T*<')I;G1/;CH@85-T
M<F5A;2!S:6=N:69I8V%N=$9I9W5R97,Z(&%N26YT96=E<@T*"2)!<'!E;F0@
M=&AE('!R:6YT960@<F5P<F5S96YT871I;VX@;V8@=&AE(')E8V5I=F5R('1O
M(&%3=')E86T@=VET: T*"6%N26YT96=E<B!S:6=N:69I8V%N="!F:6=U<F5S
M+B!%;G-U<F4@=&AA="!T:&5R92!I<R!A;'=A>7,@82!D:6=I= T*"69O;&QO
M=VEN9R!T:&4@9&5C:6UA;"!P;VEN="X-"@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