floor

Returns the greatest integer less than or equal to the receiver.

import { Arith } from "@teakit/arith";

Arith.from("1.8").floor().toString(); // "1"
Arith.from("-1.8").floor().toString(); // "-2"
Arith.from("2").floor().toString(); // "2"

// floor is equivalent to integer rounding toward negative infinity.
Arith.from("123.456").integerValue(Arith.ROUND_FLOOR).toString(); // "123"
Arith.from("-12.7").integerValue(Arith.ROUND_FLOOR).toString(); // "-13"

// Use the static helper when no method chain is needed.
Arith.floor("-1.8").toString(); // "-2"

API Reference

Signature

floor(): ArithInstance;

Parameters

This method does not take parameters.

Returns

Returns a new Arith instance rounded toward negative infinity.

Throws

  • Does not take user arguments; no argument validation is performed.

Agent Contract

FieldValue
Kindinstance method and static helper
Canonical namefloor
AliasesNone
Mutates receiverNo
ReturnsArithInstance
Accepts (string, base) overloadNo
Configuration dependenciesNone
Related methodsceil, round, trunc, integerValue

Agent Notes

  • Prefer floor() over integerValue(Arith.ROUND_FLOOR) in generated business code.
  • Use Arith.from(...) to create values. Do not generate new Arith(...) or Arith(...).
  • Treat Arith instances as immutable.