☰

# std/lenientops

Theme:

- Manual
- Standard library
- Index
- Compiler docs
- Fusion docs
- devel, stable

Search:
Source Edit

This module offers implementations of common binary operations like `+`, `-`, `*`, `/` and comparison operations, which work for mixed float/int operands. All operations convert the integer operand into the type of the float operand. For numerical expressions, the return type is always the type of the float involved in the expression, i.e., there is no auto conversion from float32 to float64.

Note: In general, auto-converting from int to float loses information, which is why these operators live in a separate module. Use with care.

Regarding binary comparison, this module only provides unequal operators. The equality operator `==` is omitted, because depending on the use case either casting to float or rounding to int might be preferred, and users should make an explicit choice.

# Procs

    func `*`[I: SomeInteger; F: SomeFloat](f: F; i: I): F {.inline.}

  Source Edit

    func `*`[I: SomeInteger; F: SomeFloat](i: I; f: F): F {.inline.}

  Source Edit

    func `+`[I: SomeInteger; F: SomeFloat](f: F; i: I): F {.inline.}

  Source Edit

    func `+`[I: SomeInteger; F: SomeFloat](i: I; f: F): F {.inline.}

  Source Edit

    func `-`[I: SomeInteger; F: SomeFloat](f: F; i: I): F {.inline.}

  Source Edit

    func `-`[I: SomeInteger; F: SomeFloat](i: I; f: F): F {.inline.}

  Source Edit

    func `/`[I: SomeInteger; F: SomeFloat](f: F; i: I): F {.inline.}

  Source Edit

    func `/`[I: SomeInteger; F: SomeFloat](i: I; f: F): F {.inline.}

  Source Edit

    func `<`[I: SomeInteger; F: SomeFloat](f: F; i: I): bool {.inline.}

  Source Edit

    func `<`[I: SomeInteger; F: SomeFloat](i: I; f: F): bool {.inline.}

  Source Edit

    func `<=`[I: SomeInteger; F: SomeFloat](f: F; i: I): bool {.inline.}

  Source Edit

    func `<=`[I: SomeInteger; F: SomeFloat](i: I; f: F): bool {.inline.}

  Source Edit