There's been a lot of questions on rounding by significant figures, and answers that that provides a new method to do the rounding, such as:
Rounding to an arbitrary number of significant digits
Round a double to 2 decimal places
Most of these questions and solutions are around 2009~2010.
I want to have a simple built in method (or from standard well know libraries such as from Apache or Spring) that given the number and significant figures, prints out the number limited to the specified significant figure.
Ie:
- 123.456789 // to 2 signficant figures: 120
- 123.456789 // to 4 signficant figures: 123.4
- 123.456789 // to 7 signficant figures: 123.4567