Do a search on the forum. There are many, many threads about this as most coders (especially newbie coders) don't understand that floating-point is represented in binary form which cannot equate to exact decimal values in all cases.
Do do the search and read-up on the information presented.
Floating-point has an infinite number of decimals, it's you, not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia
See also The == operand. - MQL4 programming forum 2013.06.07
If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
question about decima of marketinfo() - MQL4 programming forum 2016.05.18
Do a search on the forum. There are many, many threads about this as most coders (especially newbie coders) don't understand that floating-point is represented in binary form which cannot equate to exact decimal values in all cases.
Do do the search and read-up on the information presented.
Thanks I will look into this more
Floating-point has an infinite number of decimals, it's you, not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia
See also The == operand. - MQL4 programming forum 2013.06.07
If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
question about decima of marketinfo() - MQL4 programming forum 2016.05.18
thanks okay i will look into this
This is how floating-point doubles work. All numbers >= 2^53 (9007199254740992) are even integers. Odd numbers greater than 2^53 are rounded to the nearest even.
You can use this link to check it: https://baseconvert.com/ieee-754-floating-point
- baseconvert.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, im having trouble understanding why im getting the following return.
In the following code :
number = 9553700000000000
But when i move the 1st digit down to 8 as follows :
number = 8553700000000001
The last digit is 1
It seems whenever number is at 0.9 or above it returns 0 at end but, at or below 0.8 it returns 1 at end?
Very odd theres something i dont understand here.
Can someone please explain