public static BigDecimal deserializeBigDecimalFromString ( String decimal ) throws IOException { if ( decimal == null ) { return null ; } BigDecimal bd = new BigDecimal ( decimal ) ; // if the scale is too large, check for trailing zeros if ( bd . scale ( ) > kDefaultScale ) { bd = bd . stripTrailingZeros ( ) ; if ( bd . scale ( ) > kDefaultScale ) { bd = roundToScale ( bd , kDefaultScale , getRoundingMode ( ) ) ; } } // enforce scale 12 to make the precision check right if ( bd . scale ( ) < kDefaultScale ) { bd = bd . setScale ( kDefaultScale ) ; } if ( bd . precision ( ) > 38 ) { throw new RuntimeException ( "Decimal " + bd + " has more than " + kDefaultPrecision + " digits of precision." ) ; } return bd ; }
Deserialize a Volt fixed precision and scale 16 - byte decimal from a String representation