Sign in to follow this  
Followers 0
ShadowElf

number format

5 posts in this topic

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

Share this post


Link to post
Share on other sites



#3 ·  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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$x=1234.568
$y=1234.562
MsgBox(0x2000, "", "x = " & Round($x, 2))
MsgBox(0x2000, "", "x = " & Round($y, 2))

Check the help file.

EDIT: Wow. Split second postings... x_x

Edited by omikron48

Share this post


Link to post
Share on other sites

thx all, strigformat do what I want


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

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0