sanostol Posted August 25, 2011 Share Posted August 25, 2011 I must be blind, I can not find that function, that convert a float into a string Martin Quote Link to comment Share on other sites More sharing options...
Erik_JE Posted August 25, 2011 Share Posted August 25, 2011 You can use sprintf. http://www.sidefx.com/docs/houdini11.1/vex/functions/sprintf http://www.sidefx.com/docs/houdini11.1/vex/functions/printf Quote Link to comment Share on other sites More sharing options...
sanostol Posted August 26, 2011 Author Share Posted August 26, 2011 thank You 1 Quote Link to comment Share on other sites More sharing options...
sebkaine Posted June 6, 2016 Share Posted June 6, 2016 well sprintf doens't look to work for me string s = sprintf(f@class); return an error ! Is there any alternative to Convert a float value to a string value Thanks ! Quote Link to comment Share on other sites More sharing options...
rich_lord Posted June 6, 2016 Share Posted June 6, 2016 You'd use sprintf like this in this situation (i think..). string s = sprintf("%g",f@class); 3 1 Quote Link to comment Share on other sites More sharing options...
sebkaine Posted June 6, 2016 Share Posted June 6, 2016 Thanks Richard , it work ! Quote Link to comment Share on other sites More sharing options...
Skybar Posted June 6, 2016 Share Posted June 6, 2016 Question: We have atoi() and itoa() where you can convert a string to integer/vice versa. And then we have atof() which converts a string to float - but no equivalent for the other way around. Am I missing something or does it simply not exist? Quote Link to comment Share on other sites More sharing options...
sebkaine Posted June 6, 2016 Share Posted June 6, 2016 That look correct to me David, you have atof() but not the reverse function so you have to use the hack synthax describe by Richard to emulate ftoa() Quote Link to comment Share on other sites More sharing options...
pezetko Posted June 6, 2016 Share Posted June 6, 2016 string ftoa(float in){ return sprintf("%g", in); } s@str = ftoa(f@a); 1 1 Quote Link to comment Share on other sites More sharing options...
sebkaine Posted June 7, 2016 Share Posted June 7, 2016 Thanks Petr ! but that would also be logical to have ftoa natively ! Quote Link to comment Share on other sites More sharing options...
anim Posted June 7, 2016 Share Posted June 7, 2016 well, sprintf() can do more to floats than just "convert", (maybe that is the reason plain ftoa() doesn't exist?) you can specify the padding and number of decimal points it will round to, like: sprintf("%08.3f", value); unfortunately, when I just tried it seems to be broken for some reason Quote Link to comment Share on other sites More sharing options...
f1480187 Posted June 7, 2016 Share Posted June 7, 2016 Maybe it worked several years ago, but not now. Broken for a while. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.