Lua ult()

noahpgordon's avatar
Published Oct 15, 2023
Contribute to Docs

The ult() method takes two integers as arguments and compares their absolute values. The method will return true if and only if the first value is less than the second value. Otherwise, it will return false.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.
    • Beginner Friendly.
      4 hours

Syntax

The syntax of ult() is as follows:

math.ult(int1, int2)

Where int1 and int2 are the integer arguments to be compared.

Examples

The following examples illustrate the behavior of ult():

print(math.ult(5,6))
print(math.ult(5,-6)) --lua will convert '-6' to the unsigned integer '6' when performing this call
print(math.ult(5,5))
print(math.ult(5,4))

This results in the output:

true
true
false
false

All contributors

Contribute to Docs

Learn Lua on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.
    • Beginner Friendly.
      4 hours