1. Sequence question

I have been having round off issues which hint that the elements of a sequence whicb are real numbers only have an accurace of about 8 digits. I had thought they were 16 digits. Can someone comment on sequence elements which are numberic. Most of mine (a record) have a mixture of numbers and character strings.

new topic     » topic index » view message » categorize

2. Re: Sequence question

gwalters said...

I have been having round off issues which hint that the elements of a sequence whicb are real numbers only have an accurace of about 8 digits. I had thought they were 16 digits. Can someone comment on sequence elements which are numberic. Most of mine (a record) have a mixture of numbers and character strings.

Euphoria atoms are stored as 64-bit floating point numbers (often referred to as double precision floating point). They store values as binary, so anything that cannot be represented like that can suffer from rounding errors when you display them.

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: Sequence question

I ran into the problem you are talking about many years back. What Matt is telling you in his reply is true, but there is a gothcha.

I'm not completely remembering the details but the sequence contains the accuracy he indicates. But when you print the value or convert the value to text characters to place in a file the print/printf or something defaults you to 8 decimal points of accuracy (at least it did in version 3.0). There is a way to tell euphoria you want more accuracy, but I forget how.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Sequence question

mindwalker said...

I'm not completely remembering the details but ... when you print the value or ... something defaults you to 8 decimal points of accuracy (at least it did in version 3.0). There is a way to tell euphoria you want more accuracy, but I forget how.

Sounds like you are thinking of

atom i 
    i=2/3 
    ?i 
    printf(1,"%f\n",i) 
    printf(1,"%0.15f\n",i) 

which displays

0.6666666667 
0.666667 
0.666666666666667 

HTH, Pete

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu