Question

The title says it all. It's not that I don't like this functionality or anything I just want to know if it's posable to have the number return without any scientific notation attached to it.

returns --> 1.25e-10

what I would like to see --> .000000000125

I looked at the man pages of expr but all it really says that it can handle such values not that it will convert them.

Also I know I can just write something to handle this problem, but I just want to know if there something already built in that I missed or a cool trick.

Thanks!

Était-ce utile?

La solution

the result of an expr is internally represented as a float. When you turn it back to a string in an implicit way, you get a lossless* string conversion, which is most readable in scientific notation, so that's what's used. If you don't want that, don't let tcl do the conversion, but be wary that you give up the exact string representation:

% puts [expr {1. / 8 / 1000000}]
1.25e-7
% puts [format "%f" [expr {1. / 8 / 1000000}]]
0.000000
% puts [format "%.20f" [expr {1. / 8 / 1000000}]]
0.00000012500000000000

*lossless only as of Tcl8.5

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top