[squeak-dev] Rounding to n significant digits?

Bert Freudenberg bert at freudenbergs.de
Thu Aug 4 09:20:41 UTC 2011


I'd like to print decimal Floats with at most n significant digits. E.g.

	123456 roundToSignificantDigits: 3
	=> 123000
	0.00123456 roundToSignificantDigits: 3
	=> 0.00123

Would this generally be useful? If so, what would a good selector be? And what a good implementation? Instead of rounding I'd be happy to just get a String.

Thanks :)

- Bert -

More information about the Squeak-dev mailing list