public T mod ( T modulus ) { if ( modulus == null ) { throw new IllegalArgumentException ( "invalid (null) modulus" ) ; } double difference = this . value . doubleValue ( ) % modulus . doubleValue ( ) ; return newInstance ( BigDecimal . valueOf ( difference ) , this . value . scale ( ) ) ; }
This method calculates the mod between to T values by first casting to doubles and then by performing the % operation on the two primitives .