[BUG] Arithmetic troubles about float numbers

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

[BUG] Arithmetic troubles about float numbers

Guillaume Grondin
Hello.

I am experimenting some troubles with float and fraction numbers.

Two problems :

1) Any number containing 10 digits and over cannot be converted in a float.
Ex : 1234567890 asFloat  "210.0" (similar problem for 0.1234567890)
Consequence: arithmetic calculations using #asFloat may be erroneous
Solution: at least, a notification when the number to be converted in
float contains too much digits

2) Correction of the approximate value (float) of a fraction (see
Fraction>>#asFloat)
Ex:
(637629679868427784505109440202397271654068317554218172555028 /
16543612251060553497428173841399257071316242218017578125) asFloat.
"67720.5333333333" "ERRONEOUS!"
(637629679868427784505109440202397271654068317554218172555028 //
16543612251060553497428173841399257071316242218017578125) asFloat.
"38542.0"
Consequence: impossible to approximate some fractions
Solution: correction of Fraction>>#asFloat ?


Guillaume Grondin

PS : I use win32 VM (3.7.1) and 3.9b-7033 image.

--
Guillaume Grondin
===========================================
Elève-Chercheur en Informatique
Département GIP, Ecole des Mines de Douai
941, rue Charles Bourseul
BP 10838 - 59508 Douai Cedex
Tél : (+33) (0) 3 27 71 24 53
Fax : (+33) (0) 3 27 71 29 17
Email: [hidden email]




Reply | Threaded
Open this post in threaded view
|

Re: [BUG] Arithmetic troubles about float numbers

Bert Freudenberg-3
Am 22.06.2006 um 19:06 schrieb Guillaume GRONDIN:

> Hello.
>
> I am experimenting some troubles with float and fraction numbers.
>
> Two problems :
>
> 1) Any number containing 10 digits and over cannot be converted in  
> a float.
> Ex : 1234567890 asFloat  "210.0" (similar problem for 0.1234567890)
> Consequence: arithmetic calculations using #asFloat may be erroneous
> Solution: at least, a notification when the number to be converted  
> in float contains too much digits
>
> 2) Correction of the approximate value (float) of a fraction (see  
> Fraction>>#asFloat)
> Ex:
> (637629679868427784505109440202397271654068317554218172555028 /  
> 16543612251060553497428173841399257071316242218017578125) asFloat.  
> "67720.5333333333" "ERRONEOUS!"
> (637629679868427784505109440202397271654068317554218172555028 //  
> 16543612251060553497428173841399257071316242218017578125) asFloat.  
> "38542.0"
> Consequence: impossible to approximate some fractions
> Solution: correction of Fraction>>#asFloat ?
>
>
> Guillaume Grondin
>
> PS : I use win32 VM (3.7.1) and 3.9b-7033 image.

Both worked fine in 3.8.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: [BUG] Arithmetic troubles about float numbers

Tom Phoenix
In reply to this post by Guillaume Grondin
On 6/22/06, Guillaume GRONDIN <[hidden email]> wrote:

> 1) Any number containing 10 digits and over cannot be converted in a float.
> Ex : 1234567890 asFloat  "210.0" (similar problem for 0.1234567890)

Works for me, with a 3.8 on a Mac OS X VM. I don't know why you're
having troubles. What does your TestRunner do on a FloatTest?

> Consequence: arithmetic calculations using #asFloat may be erroneous

Calculations using floating point approximations may be erroneous for
many, many reasons. But this shouldn't be one of them.

> (637629679868427784505109440202397271654068317554218172555028 /
> 16543612251060553497428173841399257071316242218017578125) asFloat.
> "67720.5333333333" "ERRONEOUS!"

Again, I'm getting what seems to be the correct answer; not at all
what you're seeing.

> PS : I use win32 VM (3.7.1) and 3.9b-7033 image.

Try with a "fresh" 3.8 or 3.9 image and see whether you get the same
things. Good luck with it!

--Tom Phoenix

Reply | Threaded
Open this post in threaded view
|

Re: [BUG] Arithmetic troubles about float numbers

Guillaume Grondin
Indeed, my image was just broken.
Thx

Guillaume

Tom Phoenix wrote:

> On 6/22/06, Guillaume GRONDIN <[hidden email]> wrote:
>
>> 1) Any number containing 10 digits and over cannot be converted in a
>> float.
>> Ex : 1234567890 asFloat  "210.0" (similar problem for 0.1234567890)
>
> Works for me, with a 3.8 on a Mac OS X VM. I don't know why you're
> having troubles. What does your TestRunner do on a FloatTest?
>
>> Consequence: arithmetic calculations using #asFloat may be erroneous
>
> Calculations using floating point approximations may be erroneous for
> many, many reasons. But this shouldn't be one of them.
>
>> (637629679868427784505109440202397271654068317554218172555028 /
>> 16543612251060553497428173841399257071316242218017578125) asFloat.
>> "67720.5333333333" "ERRONEOUS!"
>
> Again, I'm getting what seems to be the correct answer; not at all
> what you're seeing.
>
>> PS : I use win32 VM (3.7.1) and 3.9b-7033 image.
>
> Try with a "fresh" 3.8 or 3.9 image and see whether you get the same
> things. Good luck with it!
>
> --Tom Phoenix
>
>

--
Guillaume Grondin
===========================================
Elève-Chercheur en Informatique
Département GIP, Ecole des Mines de Douai
941, rue Charles Bourseul
BP 10838 - 59508 Douai Cedex
Tél : (+33) (0) 3 27 71 24 53
Fax : (+33) (0) 3 27 71 29 17
Email: [hidden email]