MCPcopy Index your code
hub / github.com/clojure/clojure / toBigDecimal

Method toBigDecimal

src/jvm/clojure/lang/Numbers.java:297–322  ·  view source on GitHub ↗
(Object x)

Source from the content-addressed store, hash-verified

295}
296
297@WarnBoxedMath(false)
298static BigDecimal toBigDecimal(Object x){
299 if(x instanceof BigDecimal)
300 return (BigDecimal) x;
301 else if(x instanceof BigInt)
302 {
303 BigInt bi = (BigInt) x;
304 if(bi.bipart == null)
305 return BigDecimal.valueOf(bi.lpart);
306 else
307 return new BigDecimal(bi.bipart);
308 }
309 else if(x instanceof BigInteger)
310 return new BigDecimal((BigInteger) x);
311 else if(x instanceof Double)
312 return new BigDecimal(((Number) x).doubleValue());
313 else if(x instanceof Float)
314 return new BigDecimal(((Number) x).doubleValue());
315 else if(x instanceof Ratio)
316 {
317 Ratio r = (Ratio)x;
318 return (BigDecimal)divide(new BigDecimal(r.numerator), r.denominator);
319 }
320 else
321 return BigDecimal.valueOf(((Number) x).longValue());
322}
323
324@WarnBoxedMath(false)
325static public Ratio toRatio(Object x){

Callers 9

addMethod · 0.45
multiplyMethod · 0.45
divideMethod · 0.45
quotientMethod · 0.45
remainderMethod · 0.45
equivMethod · 0.45
ltMethod · 0.45
lteMethod · 0.45
gteMethod · 0.45

Calls 4

divideMethod · 0.95
valueOfMethod · 0.45
doubleValueMethod · 0.45
longValueMethod · 0.45

Tested by

no test coverage detected