1 package org.djunits.value.formatter; 2 3 /** 4 * Format a floating point number in a reasonable way. <br> 5 * I've experienced problems with the %g conversions that caused array bounds violations. Those versions of the JRE that do 6 * <b>not</b> throw such Exceptions use one digit less than specified in the %g conversions. <br > 7 * TODO check how to always format numbers corresponding to the Locale used. 8 * <p> 9 * Copyright (c) 2015-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 10 * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>. 11 * </p> 12 * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a> 13 * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a> 14 */ 15 public final class Format 16 { 17 /** 18 * This class shall never be instantiated. 19 */ 20 private Format() 21 { 22 // Prevent instantiation of this class 23 } 24 25 /** Default total width of formatted value. */ 26 public static final int DEFAULTSIZE = 10; 27 28 /** 29 * Format a floating point value. 30 * @param value double; the value to format 31 * @return String; the formatted floating point value 32 */ 33 public static String format(final double value) 34 { 35 return EngineeringFormatter.format(value, DEFAULTSIZE); 36 } 37 38 }