- CAN ANYONE HELP ME TO CODE EA TO WORK ONLY FOR ONE FOREX BROKER'S ACCOUNT NUMBER
- How to make 1379.000000 => 1379.0000 ??? in MT4?
- How to get profit value of last 2 position in MT5???
double price = 1.26587; int last = int(price / _point + 0.5) % 1000; // 126587 % 1000 = 587
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
The 0.5 rounds any round off to the nearest integer.
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
The 0.5 rounds any round off to the nearest integer.
Give me an example of a number which will NOT work without your 0.5 rounding... you already asked for integer ...and it doesn't matter if it is an infinity of decimals... you selected the first 5 decimals after coma because you divided initially to _Point (0.00001)...so if you have 1.12345678912345679812345679....... and you divide by 0.00001...you wil have 112345,6789123465798132456798...... and then % 1000... result is 345..but I am not experienced... please show me why do we need to complicate
Give me an example of a number which will NOT work without your 0.5 rounding... you already asked for integer ...and it doesn't matter if it is an infinity of decimals... you selected the first 5 decimals after coma because you divided initially to _Point (0.00001)...so if you have 1.12345678912345679812345679....... and you divide by 0.00001...you wil have 112345,6789123465798132456798...... and then % 1000... result is 345..but I am not experienced... please show me why do we need to complicate
I'll give you an example
double price=0.90999; int last = int(price / _Point + 0.5) % 1000; int last2 = int(price / _Point) % 1000; Print("last = ",last); Print("last2 = ",last2);
last will print 999
last2 will print 998
I just gave an example. It is William who was right. He put me on the right track years ago with floating point numbers.
No...William gave me a bunch of crap to read...you gave me example... and I took the pen and piece o paper and understood why you are right.
William gave me this : Double-precision floating-point format (sometimes called FP64 or float64) is a computer number format, usually occupying 64 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.
So thank you both of you.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use