Jump to content

VEX - converting ints and floats to strings

Recommended Posts


So basically I have a certain float value, lets say 3.68, and I want to get the digits before the comma (there are no functions that rounds to the lowest integer), so that I can later use that in some math operations.

I know I can use split() to split to the point, and sprintf() to convert to string, but I cant get this last function to work, for example if I wrote

float _x = sprintf("%g",3.68); 

But this gives me an error...

Anyone knows how to convert to string and back to the original variable type?



Share this post

Link to post
Share on other sites


I didnt know those functions...


Also I was searching for a function to round to the larger integer but I managed to do that by doing this thing on the number I need to round:

Example with 2.81:               2.81 + (1- (2.81%1))

Thanks a lot :)

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