java.lang.Object
org.sejda.sambox.util.NumberFormatUtil
This class contains methods to format numbers.
- Author:
- Michael Doswald
-
Method Summary
Modifier and TypeMethodDescriptionstatic intformatFloatFast(float value, int maxFractionDigits, byte[] asciiBuffer) Fast variant to format a floating point value to a ASCII-string.
-
Method Details
-
formatFloatFast
public static int formatFloatFast(float value, int maxFractionDigits, byte[] asciiBuffer) Fast variant to format a floating point value to a ASCII-string. The format will fail if the value is greater thanLong.MAX_VALUE, smaller or equal toLong.MIN_VALUE, isFloat.NaN, infinite or the number of requested fraction digits is greater thanMAX_FRACTION_DIGITS. When the number contains more fractional digits thanmaxFractionDigitsthe value will be rounded. Rounding is done to the nearest possible value, with the tie breaking rule of rounding away from zero.- Parameters:
value- The float value to formatmaxFractionDigits- The maximum number of fraction digits usedasciiBuffer- The output buffer to write the formatted value to- Returns:
- The number of bytes used in the buffer or
-1if formatting failed
-