floatToFixed static method

String floatToFixed(
  1. double val, [
  2. int? width
])

Implementation

static String floatToFixed( double val, [int? width] ){
	String str;
	if( width == null ){
		str = val.toStringAsFixed( 6 );
		if( (str.contains( "e" )) || (str.contains( "E" )) ){
			str = val.toStringAsExponential();
		}
	} else {
		if( width < 0 ){
			width = 0;
		}
		if( width > 20 ){
			width = 20;
		}
		str = val.toStringAsFixed( width );
		if( (str.contains( "e" )) || (str.contains( "E" )) ){
			str = val.toStringAsExponential( width );
		}
	}
	return _trimFloatStr( str );
}