Jump to content
  • Advertisement
Sign in to follow this  
circassia

Convert Integer to Floating Point value

This topic is 2625 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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.


.
..
{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},
..
.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!