# How can convert 0.004499807884787987 to 0.0044

I have this value  0.004499807884787987

I want only 0.0044

what math function should use

thanks

LONNV:

I have this value  0.004499807884787987

I want only 0.0044

what math function should use

thanks

```double abc= 0.004499807884787987;
string abc1=StringSubstr(DoubleToStr(abc,10),0,6);
Print("String: ",abc1, " Double:  ",string(abc1), " NormalizeDouble: ",NormalizeDouble(abc,4));```

Sorry @Mehmet Bastem ND would change 0.00449 to 0.0045. Not what OP asked for.

DoubleToString and

StringToDouble

amando: DoubleToString and StringToDouble

Those work only for OP's question of truncation. #1 answer provided rounding an round up as well.

LONNV:

I have this value  0.004499807884787987

I want only 0.0044

what math function should use

thanks

string valueStr = DoubleToString(0.004499807884787987,10);//10 digits or  could be anything more than 4

string   newStr = StringSubstr(valueStr, 0, 6);

double valInDoubls = StringToDouble(newStr);// this will give you value 0.0044

string backInStr = DoubleToStr(valInDoubls,4);//Convert for printing purpose

Print("NewVal - "+newStr+" valInDoubls   : "+backInStr);

You will see  valInDoubls  as 0.0044

NewVal - 0.0044 valInDoubls   : 0.0044

Ashok Nale:

string valueStr = DoubleToString(0.004499807884787987,10);//10 digits or  could be anything more than 4

string   newStr = StringSubstr(valueStr, 0, 6);

double valInDoubls = StringToDouble(newStr);// this will give you value 0.0044

string backInStr = DoubleToStr(valInDoubls,4);//Convert for printing purpose

Print("NewVal - "+newStr+" valInDoubls   : "+backInStr);

You will see  valInDoubls  as 0.0044

NewVal - 0.0044 valInDoubls   : 0.0044

in this case it can be digits more than 8 for truncation.

Ashok Nale:

string valueStr = DoubleToString(0.004499807884787987,10);//10 digits or  could be anything more than 4

string   newStr = StringSubstr(valueStr, 0, 6);

double valInDoubls = StringToDouble(newStr);// this will give you value 0.0044

string backInStr = DoubleToStr(valInDoubls,4);//Convert for printing purpose

Print("NewVal - "+newStr+" valInDoubls   : "+backInStr);

You will see  valInDoubls  as 0.0044

NewVal - 0.0044 valInDoubls   : 0.0044

In fact it is same as solution provided by  Mehmet Bastem but there was error. It should have been

`NormalizeDouble(abc1,4)`

`MathFloor(0.004499807884787987*10000)/10000; `

I personally would use double <-> int conversion.

Like this:

int x = (int)(0.0044.... * pow(10, 4));
double result = x / pow(10, 4);

That should do the trick.

I suppose you are using a 4 digit symbol, so the pow function can be fed with the symbols digits. Thus it will adapt to whatever environment you are in.

Also it should be faster than converting between strings and doubles.