How do I format decimal places?

 
For example, I am using a custom indicator that returns something like 1.37895645 which is 8 decimal places, but all I want are the first 4. Is there a way to truncate the rest off? Thanks in advance.
 

double NormalizeDouble( double value, int digits)


https://docs.mql4.com/convert/NormalizeDouble


NormalizeDouble(1.4513, 2) yields 1.45

 
Thank you!
 

Actually, its still not working as I thought it would. I want to print the value produced out onto the chart so the code I have is this:

string blueval = NormalizeDouble(blue[0],4);
ObjectCreate("BlueVal", OBJ_LABEL, 0, 0, 0);
ObjectSet("BlueVal", OBJPROP_CORNER, 0);
ObjectSet("BlueVal", OBJPROP_XDISTANCE, 10);
ObjectSet("BlueVal", OBJPROP_YDISTANCE, 15);
ObjectSetText("BlueVal", blueval, 10, "Arial", Blue);

where blue[0] is the original double figure of 1.37895645 (or similar). The current output on the chart is 1.37890000 os similar. I'd like it to be 1.3789 - without the trailing figures!

Thanks again in advance...

 

Since you are converting it into a string try:


https://docs.mql4.com/convert/DoubleToStr


string DoubleToStr( double value, int digits)
Returns text string with the specified numerical value converted into a specified precision format.
Parameters:
value - Floating point value.
digits - Precision format, number of digits after decimal point (0-8).
Sample:
  string value=DoubleToStr(1.28473418, 5);
// the value is "1.28473"
 
Thats done it - thanks again.
Reason: