söndag 29 mars 2015

bigdec, decimal?, integer?

The function bigdec returns a java.math.BigDecimal.

If you want to test it you can use decimal? instead of defining your own function bigdec?

integer? does not test the value for not having decimals, but for being some natively decimal number type.

(defn no-decimal-part?
  "converts the number to bigdec,
  make sure a division by
  zero has remainder exactly zero"
  (zero? (.remainder (bigdec number) java.math.BigDecimal/ONE)))

is better to use to make sure the bigdec does not have any decimals.

Inga kommentarer:

Skicka en kommentar