Download MetaTrader 5

trim to 5 decimal places

To add comments, please log in or register
CM
46
CM  

I'm using NormalizeDouble() to round a number to the 5th decimal place but the problem is that it keeps all the zeroes at the end. For example: 1.2345600000.


How can I trim the number to 5 decimal places, getting rid of the zeroes?

Tom
40
Tom  
string DoubleToStr( double value, int digits)
  string value=DoubleToStr(1.28473418, 5);
  // the value is "1.28473"
selnomeria
254
selnomeria  
Any solution there? the above is not solution, it is conversion into STRING!!!
honest_knave
Moderator
2326
honest_knave  

It is a solution.

Don't confuse what the number actually is with how you want the number displayed.

There is no difference between 1.2345600000 and 1.23456 except how it is displayed.

Now we are teetering on the edge of 2 forum bugbears - NormalizeDouble and how floating point numbers are stored in binary 

To add comments, please log in or register