[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

No error - read about IEEE standard for floating point arithmetic, Re: [amibroker] Amibroker calculation error


  • To: <amibroker@xxxxxxxxxxxxxxx>
  • Subject: No error - read about IEEE standard for floating point arithmetic, Re: [amibroker] Amibroker calculation error
  • From: "Tomasz Janeczko" <groups@xxxxxxxxxxxxx>
  • Date: Mon, 14 May 2007 07:57:28 +0200

PureBytes Links

Trading Reference Links

Hello,
 
There is no error.
 
As discussed hundreds of times on this list - there is no *integer* arithmetic in AFL.
 
All numbers are represented in FLOATING POINT, Standard Single Precision IEEE754 standard format.
 
 
There single precision format is 32 bit with 23 bit for mantissa and 8 bits for fraction and 1 bit for sign.
Single precision IEEE offers 7+ significant digit precision.
 
So technically there is NO error. You are just displaying the numbers past the significant digits.
 
That is the reason why AB uses DateNum format of YYYMMDD (where YYY is (year-1900))..
 
For dates you should use DATETIME format !
 
AddColumn( DateTime(), "DateTime", formatDateTime );

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: Mark H
Sent: Monday, May 14, 2007 4:23 AM
Subject: [amibroker] Amibroker calculation error

I am trying to convert a date number to a year+month+day number for better display.

It worked before, but for May 11, I got this error:

1070511 + 19000000 = 20070512 instead of 20070511.

Here is a piece of code to demonstrate this calculation error:

 

---------------------------------------------------------

filter = 1;

daten = StrFormat("%f", 1070511 + 19000000);

AddTextColumn(daten, "DateNum");

buy = 1;

---------------------------------------------------------

The column will display 20070512.00000, not 20070511 as you would expect.

I understand that in AFL, all numbers are in double type and integer is converted when used. However, this doesn?t seem to be a rounding error since the result is exactly 20070512.00000, not something like 20070511.71332.

 

I am using 4.90.5.

Have anyone seen this before?

 

Thanks,

 

- Mark

__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___