commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Tompkins (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (LANG-1408) NumberUtils: Rounding utilities for BigDecimal to primitive double avoiding NPEs.
Date Tue, 14 Aug 2018 19:51:00 GMT

     [ https://issues.apache.org/jira/browse/LANG-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Rob Tompkins resolved LANG-1408.
--------------------------------
    Resolution: Fixed

https://github.com/apache/commons-lang/commit/08aa21f9217df0a28d48be5be5db03ddf4867140
and
https://github.com/apache/commons-lang/commit/b31877a46009d5ee52af9b5f737dabe241689931

> NumberUtils: Rounding utilities for BigDecimal to primitive double avoiding NPEs.
> ---------------------------------------------------------------------------------
>
>                 Key: LANG-1408
>                 URL: https://issues.apache.org/jira/browse/LANG-1408
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Rob Tompkins
>            Assignee: Rob Tompkins
>            Priority: Minor
>             Fix For: 3.8
>
>
> For the sake of formatting rounded {{BigDecimal}} values in JSON/XML I'm looking for
the following methods:
> 1. 
> {code:java}
> public static double toDouble(BigDecimal value);
> {code}
> that defaults to {{0}} when {{value}} is null.
> 2.
> {code:java}
> public static double toDouble(BigDecimal value, double defaultValue);
> {code}
> that essentially does the same as 1. but accommodates for default values being specified.
> 3. 
> {code:java}
> public static BigDecimal toScaledBigDecimal(BigDecimal value, Integer scale, RoundingMode
roudingMode);
> that converts a {{BigDecimal}} to a {{BigDecimal}} whose scale is the specified value
with input rounding mode applied
> {code}
> 4. 
> {code:java}
> public static BigDecimal toScaledBigDecimal(BigDecimal value);
> {code}
> that converts a {{BigDecimal}} to a {{BigDecimal}} whose scale is 2 with {{RoundingMode.HALF_UP}}
rounding mode applied.
> 5.
> {code:java}
> public static BigDecimal toScaledBigDecimal(Float value, Integer scale, RoundingMode
roudingMode);
> {code}
> that converts a {{Float}} to a {{BigDecimal}} whose scale is the specified value with
input rounding mode applied.
> 6.
> {code:java}
> public static BigDecimal toScaledBigDecimal(Double value, Integer scale, RoundingMode
roudingMode);
> {code}
> that converts a {{Double}} to a {{BigDecimal}}  whose scale is the specified value with
input rounding mode applied.
> 7.
> {code:java}
> public static BigDecimal toScaledBigDecimal(Double value);
> {code}
> that converts a {{Double}} to a {{BigDecimal}} whose scale is 2 with {{RoundingMode.HALF_UP}}
rounding mode applied.
> 8.
> {code:java}
> public static BigDecimal toScaledBigDecimal(String value, Integer scale, RoundingMode
roudingMode);
> {code}
> that converts a {{String}} to a {{BigDecimal}} whose scale is the specified value with
input rounding mode applied
> 9.
> {code:java}
> public static BigDecimal toScaledBigDecimal(String value);
> {code}
> that converts a {{String}} to a {{BigDecimal}} whose scale is 2 with {{RoundingMode.HALF_UP}}
rounding mode applied



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message