Jump to content

Recommended Posts

Posted

I want to format a number to limit it at 2 zecimals as in example

if I have $x=1234.568

$y=1234.562

format($x) to return $x=1234.57 because 8>5

format($y) to return $y=1234.56 because 2<5

exist what I want? or I have to do one?

I like IT: php, mysql, codeingiter, css, jquery and AUTOIT

Posted (edited)

$x = 1234.568
$y = 1234.562

$z = 1234.003

ConsoleWrite(StringFormat("%.2f", $x) & @LF)
ConsoleWrite(StringFormat("%.2f", $y) & @LF)
ConsoleWrite(StringFormat("%.2f", $z) & @LF)

ConsoleWrite(Round($x, 2) & @LF)
ConsoleWrite(Round($y, 2) & @LF)
ConsoleWrite(Round($z, 2) & @LF)

Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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
×
×
  • Create New...