Convert Integer to Floating Point value

Started by
0 comments, last by Juliean 12 years, 6 months ago
Dear Friends,

i am precomputing blur-weights on the cpu, some variables have integers values and i want to check if those vars have a floating point, to add a ".0". While writing this post, i was still searching and i found the solution :)

The problem occured while converting the float to a string to write into a file. The Method ToString() (in csharp) accepts arguments, to define how numbers should be handled.


.
..
{0,9999938, 3,12592E-06, 0},
{0,9999997, 1,55985E-07, 0},
{1, 2,334E-09, 0},
{1, 4E-12, 0},
{1, 0, 0},
{1, 0, 0},
{1, 0, 0},
..
.
Advertisement
Under normal circumstances, int shoulf be automatically cast int to float and other round if needed. Alternatively you could try writing

(float)value
Static_cast<float>value
Dynamic_cast<float>value


Whereever a value is read in. Dont know about the casts, (float) should do.

This topic is closed to new replies.

Advertisement