Friday, 15 August 2014

Show precise result of math expression -



Show precise result of math expression -

i want mathematical operation in tcl precise result , e.g. 2 digits after dot. example: 1/100 = 0.01. tried puts "[format "%.2f" [expr 1/100]]", did not work out.

can solve puzzle?

thanks!

tcl's partition expr operator floating point partition if @ to the lowest degree 1 of arguments floating point number. if both integers, integer division.

% expr {1/100} 0 % expr {1.0/100} 0.01 % expr {1/double(100)} 0.01

as can see above, double cast-function may help here.

math expression tcl

No comments:

Post a Comment