Hello,
The rounding is correct and actually, it is not rounding at
all it is just formatting
of floating point number. So it is for "display only".
The underlying numbers
remain the same regardless of how many digits you
display.
As to number formatting is entirely done by C runtime
library (MSVCRT.DLL), made by Microsoft
and used in almost every Windows
application.
Read about sprintf there:
There are different methods of rounding (always up, always
down, unbiased)
The way printf and sprintf functions do rounding will
often depend upon the system's C `sprintf' subroutine.
On many OSes including Windows, `sprintf'
rounding is "unbiased," which means it doesn't always round a trailing
`.5' up, contrary to naive expectations. In unbiased rounding,
`.5' rounds to even, rather than always up, so 1.5 rounds to 2 but 4.5
rounds to 4. The result is that if you are using a format that does
rounding (e.g., `"%.0f"') you should check what your system does.
If you need "always up" rounding use
floor( value + 0.5 );
Best regards, Tomasz Janeczko amibroker.com
----- Original Message -----
Sent: Saturday, March 14, 2009 7:04
AM
Subject: Re: [amibroker] Incorrect
rounding in Amibroker
Thanks a lot, but...
When we tell
AddColumn(H,"H",1.4);
AddColumn (L,"L",1.4);
AddColumn (mp,"mp",1.4);
to Amibroker, the answers are correct. (The right column
below)
However, when we don't tell that way, rounding still seems to be
incorrect.
We should format first and then round with excel...
I'll appreciate any additional comments.
Ticker |
Date/Time |
H |
L |
with excel: |
mp |
|
Ticker |
Date/Time |
H |
L |
mp |
YKBNK |
10.03.2009 |
1.55 |
1.5 |
1.525 |
1.52 |
|
YKBNK |
10.03.2009 |
1.5500 |
1.5000 |
1.5250 |
YKBNK |
11.03.2009 |
1.56 |
1.51 |
1.535 |
1.53 |
|
YKBNK |
11.03.2009 |
1.5600 |
1.5100 |
1.5350 |
On Sat, Mar 14, 2009 at 2:49 AM, Tomasz Janeczko <groups@xxxxxxxxxxxxx>
wrote:
Rounding is correct and user-definable. If you want 3
decimal digits - just tell AB this way:
AddColumn(mp,"mp", 1.3 );
----- Original Message -----
Sent: Friday, March 13, 2009 9:35
PM
Subject: [amibroker] Incorrect
rounding in Amibroker
Dear friends,
Amibroker seems to be rounding the results different than it should
be. Below is a piece of the results.
The prices have two digits after dot. (h+l)/2 sometimes has 2 digits,
sometimes 3 after dot.
Amibroker sometimes rounds the result up,
sometimes down.
|
Ticker |
Date/Time |
H |
L |
(h+l)/2 Excel Calc. |
(h+l)/2 Amibroker
Calc. |
YKBNK |
23.02.2009 |
1.67 |
1.63 |
1.65 |
1.65 |
YKBNK |
24.02.2009 |
1.64 |
1.58 |
1.61 |
1.61 |
YKBNK |
25.02.2009 |
1.69 |
1.65 |
1.67 |
1.67 |
YKBNK |
26.02.2009 |
1.70 |
1.65 |
1.675 |
1.67 |
YKBNK |
27.02.2009 |
1.66 |
1.61 |
1.635 |
1.63 |
YKBNK |
02.03.2009 |
1.63 |
1.58 |
1.605 |
1.61 |
YKBNK |
03.03.2009 |
1.62 |
1.59 |
1.605 |
1.61 |
YKBNK |
04.03.2009 |
1.64 |
1.60 |
1.62 |
1.62 |
YKBNK |
05.03.2009 |
1.62 |
1.53 |
1.575 |
1.58 |
YKBNK |
06.03.2009 |
1.57 |
1.52 |
1.545 |
1.55 |
YKBNK |
09.03.2009 |
1.59 |
1.49 |
1.54 |
1.54 |
YKBNK |
10.03.2009 |
1.55 |
1.50 |
1.525 |
1.52 |
YKBNK |
11.03.2009 |
1.56 |
1.51 |
1.535 |
1.53 |
YKBNK |
12.03.2009 |
1.55 |
1.46 |
1.505 |
1.5 |
YKBNK |
13.03.2009 |
1.60 |
1.54 |
1.57 |
1.57 |
I may also send you the complete data if needed. You may also see
easily with your own data with the following code:
MP= (H+L)/2;
Filter=1;
AddColumn (H,"H");
AddColumn (L,"L");
AddColumn (mp,"mp");
Thanks in advance for your
help.
Ilhan
__._,_.___
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
__,_._,___
|