fldmod

fldmod(x, y)

The floored quotient and modulus after division. Equivalent to (fld(x,y), mod(x,y)).

Examples

julia> fldmod(10, 3)
(3, 1)
  1. Find the floored quotient and modulus:

    julia> fldmod(17, 4)
    (4, 1)

    This example calculates the floored quotient and modulus of dividing 17 by 4.

  2. Handle negative numbers:

    julia> fldmod(-15, 7)
    (-3, 4)

    It correctly handles negative numbers and returns the floored quotient and modulus.

  3. Use with floating-point numbers:
    julia> fldmod(3.5, 1.2)
    (2.0, 1.1)

    The fldmod function can also be used with floating-point numbers. It returns the floored quotient and modulus as floating-point values.

Common mistake example:

julia> fldmod(10, 0)
ERROR: DivideError: integer division error

In this example, the divisor y is zero, causing a divide error. It's important to ensure that the divisor is non-zero to avoid such errors when using fldmod.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: