sahvx655-wq commented on code in PR #407:
URL: https://github.com/apache/commons-validator/pull/407#discussion_r3452761320


##########
src/main/java/org/apache/commons/validator/routines/BigIntegerValidator.java:
##########
@@ -79,6 +79,19 @@ public static BigIntegerValidator getInstance() {
         return VALIDATOR;
     }
 
+    private static BigDecimal toBigDecimal(final Number value) {
+        if (value instanceof BigDecimal) {
+            return (BigDecimal) value;
+        }
+        if (value instanceof BigInteger) {
+            return new BigDecimal((BigInteger) value);
+        }
+        if (value instanceof Long) {

Review Comment:
   Good catch. I've added a Double branch using BigDecimal.valueOf(((Double) 
value).doubleValue()) so it matches the toBigInteger helper just below, which 
already takes that path with the same "no need to roundtrip with a string" 
note. The fall-through stays on new BigDecimal(value.toString()) for the 
remaining types (Float keeps its own canonical short form that way rather than 
picking up the widened double representation).
   
   Pushed in 3b48460 and the range tests still pass.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to