(Number x)
| 339 | } |
| 340 | |
| 341 | @WarnBoxedMath(false) |
| 342 | static public Number rationalize(Number x){ |
| 343 | if(x instanceof Float || x instanceof Double) |
| 344 | return rationalize(BigDecimal.valueOf(x.doubleValue())); |
| 345 | else if(x instanceof BigDecimal) |
| 346 | { |
| 347 | BigDecimal bx = (BigDecimal) x; |
| 348 | BigInteger bv = bx.unscaledValue(); |
| 349 | int scale = bx.scale(); |
| 350 | if(scale < 0) |
| 351 | return BigInt.fromBigInteger(bv.multiply(BigInteger.TEN.pow(-scale))); |
| 352 | else |
| 353 | return divide(bv, BigInteger.TEN.pow(scale)); |
| 354 | } |
| 355 | return x; |
| 356 | } |
| 357 | |
| 358 | //static Number box(int val){ |
| 359 | // return Integer.valueOf(val); |
nothing calls this directly
no test coverage detected