toSignificantFigures static method

double toSignificantFigures(
  1. double value,
  2. int figures
)

Implementation

static double toSignificantFigures(double value, int figures)
{
  double multiplier = Math.pow(10.0, figures.toDouble() ).toDouble();
  return ( value*multiplier ).round() / multiplier;
}