Search code examples
mathluarobloxluau

How can I get the quotient of a division in lua?


For my game in roblox, I need the quotient of a division. For example the quotient of 20/3 is 6 and 40/2 is 20. Is there a way to do this using a function?


Solution

  • Look at math.modf(a/b), which will return two values, the intergral and the fractional remainder.

    a = 20
    b = 3
    q, _ = math.modf(a/b)
    print(q)
    

    will result in 6