Rem/modulo function for integers

Hi,

The remainder function rem/2 works on integers.

Is there a function that is able to calculate the remainder for floats.

For example.

I would like to carry out 12 % 3.5, this should return 1.5, or 12.1 % 3.5, this should return 1.6.

Is there any function, that can handle such scenarios?

The BEAM provides :math.fmod/2 which is a trivial wrapper over the C stdlib fmod.

2 Likes

…or Decimal.rem/2.

1 Like