Tom Posted October 14, 2011 Share Posted October 14, 2011 I have simple expression, that returns floating value in Font sop in Text parameter. All I want to do, is to get value, that is only with two decimal numbers, behing point, not eight. For example, i get 3.12345, but want to get only 3.12. Searched for this in help, but I didnt find. Thanks in advance, Tom. Quote Link to comment Share on other sites More sharing options...
Erik_JE Posted October 14, 2011 Share Posted October 14, 2011 printf don't seem to exist in hscript for formatting floats but you could just do a simple expression as: `round(3.12345*100)/100` Not super pretty but gets the job done Quote Link to comment Share on other sites More sharing options...
ben Posted October 14, 2011 Share Posted October 14, 2011 (edited) maybe : trunc(3.123456*100)/100 edit : round works too to but watch out that it will actually... round. round(19.999*100)/100 = 20 Edited October 14, 2011 by ben Quote Link to comment Share on other sites More sharing options...
Tom Posted October 14, 2011 Author Share Posted October 14, 2011 Thanks Erik and Benoit, both of you're solutions works Quote Link to comment Share on other sites More sharing options...
gaurav Posted October 14, 2011 Share Posted October 14, 2011 (edited) I have simple expression, that returns floating value in Font sop in Text parameter. All I want to do, is to get value, that is only with two decimal numbers, behing point, not eight. For example, i get 3.12345, but want to get only 3.12. Searched for this in help, but I didnt find. Thanks in advance, Tom. you might want to try python. Change your expression language to python > Set Keyframe on first frame and use round function in Text parameter. round(3.16159265,2) 3.16 Cheers!! Edited October 14, 2011 by vectorblur Quote Link to comment Share on other sites More sharing options...
gaurav Posted October 14, 2011 Share Posted October 14, 2011 (edited) you might want to try python. Change your expression language to python > Set Keyframe on first frame and use round function in Text parameter. round(3.16159265,2) 3.16 Cheers!! Ah my bad. just realized you are not really looking for this. it may be over killing but string slicing will do the job. a = 3.99999 b = str(a) return b[0:4] 3.99 Edited October 14, 2011 by vectorblur 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.