Simplify the total of a calculation
Hello :)
As title, my question is:
How do I simplify the calculation of a total? (Believe me, they are 2 days that I slam my head against the wall!)
I've create a script with more calculation, but I have to restrict the numbers of total in the label.
Es:
If I write "10/9.81" I have a total of "1.01937" (10kg/gravity = N). My target is to have (in the label) something like this: "1" or at most "1.0193"... (the second solution should be just fine). All this, because the calculation of volume (8123.81) and density (0.000125488), are long numbers, as you can see...
How do?
Waiting for a welcome help, a big greeting from
Michele71
Comments
formattedPrint
@kogen - nice function!
@Michele71 - if no need to touch the original value and just want to diplay it to concrete digit after the comma, then you can use
formattedPrint
function:my recent MAXScripts RSS (archive here)
Ooh Anubis... I have not
Ooh Anubis... I have not thought about formatprint...I am an idiot... Yes it work well...
Thanks for making me open my eyes :)
P.S: The function by Kogen is a surprise, but How job?
Thanks Again Anubis
Hey Michele, you might write
Hey Michele,
you might write yourself a little "rounding"-function like this:
fn round val step =
(
local mult = 10.00^(step as float)
return ((floor ((val * mult)+0.5)) / mult)
)
-- example: round 3.456234234 2 -> gives you 3.46
val is the value you want to be rounded and step is the accuracy after the point. Set it to 0 if you want to have 1.01937 returning 1.0
-k.
"Arrogance kills."
Ciao Kogen and thanks for you
Ciao Kogen and thanks for you reply :)
I have this:
_mass = (edtext.text as number /spn_grav.value)
where editText and spinner are two value.
I show the result so:
lbl1.text = _mass as string
How do I enter the function?? Sorry, but I don't understand...