C# float to decimal conversion

Posted by Adrian4B on Stack Overflow See other posts from Stack Overflow or by Adrian4B
Published on 2010-04-07T18:12:13Z Indexed on 2010/04/07 18:13 UTC
Read the original article Hit count: 151

Filed under:

Any smart way to convert a float like this: float f = 711989.98f; into a decimal (or double) without loosing precision?

I've tried: decimal d = (decimal)f; decimal d1 = (decimal)(Math.Round(f,2)); decimal d2 = Convert.ToDecimal(f);

© Stack Overflow or respective owner

Related posts about float