I\'m converting double to float using ye old float myFloat = (float)myDouble
.
This does however sometimes result in \"Infinity\", which is not good for
You can use the .NET method Convert.ToSingle()
. For example:
float newValue = Convert.ToSingle(value);
According to the MSDN Documentation:
Converts a specified value to a single-precision floating-point number.
Update:
Upon further review, Convert.ToSingle(Double.MaxValue)
results in Infinity so you still have to check for infinity as done in Jon Skeet's answer.