Sign in to follow this  
circassia

Convert Integer to Floating Point value

Recommended Posts

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.

[code]
.
..
{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},
..
.
[/code]

Share this post


Link to post
Share on other sites
Under normal circumstances, int shoulf be automatically cast int to float and other round if needed. Alternatively you could try writing

[code](float)value
Static_cast<float>value
Dynamic_cast<float>value[/code]

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this