简体   繁体   中英

Removing the trailing zeros in a double variable

i have a DLL which defines many methods which all returns double and I don't want to change anything in it. The problem is when I pass small numbers to these methods, the return values come with too many trailing zeros as the return value is double , for example 9*9=810000000000 (it's not a decimal point,it's the actual capacity of a Double variable). i want the normal behavior which is 9*9=81

How can I get rid of those trailing zeros without changing the DLL?

(Presumably your example should include a decimal point between the 81 and all those zeros?)

Surely if the result is a double, the trailing zeros are only relevant when you render the number it contains into text?

That being the case, all you need to do is format that text at the point where you need it.

Not knowing which language you're working in, I can't offer you the precise syntax for that formatting command, but a quick search on here should help you with that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM