Jump to content

Number format


botshara

Recommended Posts

Could you give some more examples, I dont understand what you want?

Maybe this can help you:

http://www.lua.org/manual/5.1/manual.html

2.5.1 – Arithmetic Operators

Lua supports the usual arithmetic operators: the binary + (addition), - (subtraction), * (multiplication), / (division), % (modulo), and ^ (exponentiation); and unary - (negation). If the operands are numbers, or strings that can be converted to numbers (see §2.2.1), then all operations have the usual meaning. Exponentiation works for any exponent. For instance, x^(-0.5) computes the inverse of the square root of x. Modulo is defined as

a % b == a - math.floor(a/b)*b

That is, it is the remainder of a division that rounds the quotient towards minus infinity.

Link to comment

This migth be useful I use it for all of my number formatting,

function comma_value(amount) 
  local formatted = amount 
  while true do   
    formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') 
    if (k==0) then 
      break 
    end 
  end 
  return formatted 
end 

Example of usage:

outputChatBox("You have recieved: $" ..comma_value(amount).. " into your bank account",source,0,255,255) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...