[Glass] '7.3470570000000004E+02' asNumber -> 7.3470570000000004E+00

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

[Glass] '7.3470570000000004E+02' asNumber -> 7.3470570000000004E+00

Mariano Martinez Peck
Terrible WTF or I am too tired?  note the +02 and the +00 ...


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] '7.3470570000000004E+02' asNumber -> 7.3470570000000004E+00

Martin McClure-5
On 05/02/2014 03:18 PM, Mariano Martinez Peck wrote:
> Terrible WTF or I am too tired?  note the +02 and the +00 ...
>

It's best to avoid putting a $+ in front of a float's exponent. The ANSI
Smalltalk standard says that this is supposed to be illegal. Various
Smalltalks do different things with it.

The results I get:

GemStone/S 64-bit 3.2
        7.3470570000000009E02

VW 7.10
        7.34706

Pharo 3.0 (pre-release)
        7.347057

VA Smalltalk 8.6
        7 (asNumber is defined to answer a SmallInteger in VA)


If I omit the $+, and make the E to be lowercase e instead (ANSI also
only recognizes e, d, and q, not the uppercase varieties), I get:

'7.3470570000000004e02' asNumber

GemStone
        7.3470570000000009E02

VW
        734.706

Pharo
        734.7057000000001

Regards,

-Martin
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

[Glass] Fwd: '7.3470570000000004E+02' asNumber -> 7.3470570000000004E+00

Dale Henrichs-3
In reply to this post by Mariano Martinez Peck
[stupid gmail] ... in addition to the response below, I've submitted a bug report[1] on this issue.

Dale

[1] https://github.com/glassdb/glass/issues/20

---------- Forwarded message ----------
From: Dale Henrichs <[hidden email]>
Date: Fri, May 2, 2014 at 3:42 PM
Subject: Re: [Glass] '7.3470570000000004E+02' asNumber -> 7.3470570000000004E+00
To: Mariano Martinez Peck <[hidden email]>


Not that this is a solution, but in pharo, you get the same answer as GemStone (i.e., the exponent is ignored).... #asNumber is based on a port of SqNumberParser, so that "makes sense."

This form of the printString produces the expected answer:

  '7.3470570000000004e02' asNumber.

Note the lower case $e and absence of $+ ...

With that said, I know that GemStone prints it's floats with a plus sign in the exponent and this is a bug that has been fixed in 3.2 ...

SqNumberParser>>exponentLetters controls the list of exponents expected and could be modified to include capital letters ...

The class ExtendedNumberParser will parse numbers with $+ in the exponent so overriding SqNumberParser class>>on: to directly use ExtendedNumberParser ... allows asNumber to accept $+ ,,,

so a patch to SqNumberParser>>exponentLetters and the SqNumber class-side methods would probably get you past this hump...

Dale


On Fri, May 2, 2014 at 3:18 PM, Mariano Martinez Peck <[hidden email]> wrote:
Terrible WTF or I am too tired?  note the +02 and the +00 ...


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass




_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Fwd: '7.3470570000000004E+02' asNumber -> 7.3470570000000004E+00

Mariano Martinez Peck
Thank you very much guys. Tomorrow I send a detailed thanks but just to confirm that implementing:

SqNumberParser class >> on: aStringOrStream
^ExtendedNumberParser new on: aStringOrStream

SqNumberParser >> exponentLetters
"answer the list of possible exponents for Numbers.
Note: this parser will not honour precision attached to the exponent.
different exponent do not lead to different precisions.
only IEEE 754 floating point numbers will be created"
^'edqEDQ'

Does solve the problem. I could now import my sixx data.

Thanks!!!



On Fri, May 2, 2014 at 7:48 PM, Dale Henrichs <[hidden email]> wrote:
[stupid gmail] ... in addition to the response below, I've submitted a bug report[1] on this issue.

Dale

[1] https://github.com/glassdb/glass/issues/20


---------- Forwarded message ----------
From: Dale Henrichs <[hidden email]>
Date: Fri, May 2, 2014 at 3:42 PM
Subject: Re: [Glass] '7.3470570000000004E+02' asNumber -> 7.3470570000000004E+00
To: Mariano Martinez Peck <[hidden email]>


Not that this is a solution, but in pharo, you get the same answer as GemStone (i.e., the exponent is ignored).... #asNumber is based on a port of SqNumberParser, so that "makes sense."

This form of the printString produces the expected answer:

  '7.3470570000000004e02' asNumber.

Note the lower case $e and absence of $+ ...

With that said, I know that GemStone prints it's floats with a plus sign in the exponent and this is a bug that has been fixed in 3.2 ...

SqNumberParser>>exponentLetters controls the list of exponents expected and could be modified to include capital letters ...

The class ExtendedNumberParser will parse numbers with $+ in the exponent so overriding SqNumberParser class>>on: to directly use ExtendedNumberParser ... allows asNumber to accept $+ ,,,

so a patch to SqNumberParser>>exponentLetters and the SqNumber class-side methods would probably get you past this hump...

Dale


On Fri, May 2, 2014 at 3:18 PM, Mariano Martinez Peck <[hidden email]> wrote:
Terrible WTF or I am too tired?  note the +02 and the +00 ...


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass




_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass




--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Fwd: '7.3470570000000004E+02' asNumber -> 7.3470570000000004E+00

Dale Henrichs-3
I confirmed that it does fix the asNumber problem:

  '7.3470570000000004E+02' asNumber -> 7.3470569999999998E+02

 .... within roundoff error...presumably you would need to touch the other `instance creation` methods in SqNumberParser to cover "all" of the bases


On Fri, May 2, 2014 at 4:54 PM, Mariano Martinez Peck <[hidden email]> wrote:
Thank you very much guys. Tomorrow I send a detailed thanks but just to confirm that implementing:

SqNumberParser class >> on: aStringOrStream
^ExtendedNumberParser new on: aStringOrStream

SqNumberParser >> exponentLetters
"answer the list of possible exponents for Numbers.
Note: this parser will not honour precision attached to the exponent.
different exponent do not lead to different precisions.
only IEEE 754 floating point numbers will be created"
^'edqEDQ'

Does solve the problem. I could now import my sixx data.

Thanks!!!



On Fri, May 2, 2014 at 7:48 PM, Dale Henrichs <[hidden email]> wrote:
[stupid gmail] ... in addition to the response below, I've submitted a bug report[1] on this issue.

Dale

[1] https://github.com/glassdb/glass/issues/20


---------- Forwarded message ----------
From: Dale Henrichs <[hidden email]>
Date: Fri, May 2, 2014 at 3:42 PM
Subject: Re: [Glass] '7.3470570000000004E+02' asNumber -> 7.3470570000000004E+00
To: Mariano Martinez Peck <[hidden email]>


Not that this is a solution, but in pharo, you get the same answer as GemStone (i.e., the exponent is ignored).... #asNumber is based on a port of SqNumberParser, so that "makes sense."

This form of the printString produces the expected answer:

  '7.3470570000000004e02' asNumber.

Note the lower case $e and absence of $+ ...

With that said, I know that GemStone prints it's floats with a plus sign in the exponent and this is a bug that has been fixed in 3.2 ...

SqNumberParser>>exponentLetters controls the list of exponents expected and could be modified to include capital letters ...

The class ExtendedNumberParser will parse numbers with $+ in the exponent so overriding SqNumberParser class>>on: to directly use ExtendedNumberParser ... allows asNumber to accept $+ ,,,

so a patch to SqNumberParser>>exponentLetters and the SqNumber class-side methods would probably get you past this hump...

Dale


On Fri, May 2, 2014 at 3:18 PM, Mariano Martinez Peck <[hidden email]> wrote:
Terrible WTF or I am too tired?  note the +02 and the +00 ...


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass




_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass




--
Mariano
http://marianopeck.wordpress.com


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass