Tc2_Math

Compatibility library for Beckhoff’s TwinCAT 3 Tc2_Math PLC library: LREAL math functions. Activated by a project reference or --library Tc2_Math.

Functions

Name

Signature

Description

LTRUNC

LTRUNC(IN : LREAL) : LREAL

Integer part of IN, rounding toward zero. Unlike the IEC TRUNC (which returns an integer type), the result stays LREAL, so values beyond any integer type’s range truncate exactly without clamping.

LMOD

LMOD(IN1 : LREAL, IN2 : LREAL) : LREAL

Floating modulo returning the signed remainder (IEEE-754 fmod): the result has the sign of IN1 and a magnitude less than that of IN2.

MODABS

MODABS(IN : LREAL, IM : LREAL) : LREAL

Modulo returning the unsigned representative in [0.0, |IM|) — the wrap-around commonly used for positioning.

FRAC

FRAC(IN : LREAL) : LREAL

Fractional part of IN: keeps the sign of the input, with a magnitude less than 1.0.

Example

angle := MODABS(IN := rawAngle, IM := 360.0);

Independence

IronPLC is an independent open-source project and is not affiliated with, endorsed by, or sponsored by the vendors whose library interfaces the compatibility libraries reproduce. Each compatibility library is authored independently from the vendor’s public documentation and contains no vendor code. See Trademarks.

See Also