Jump to content
Sign in to follow this  
Swift

How to make sure a number will always have

Recommended Posts

Swift

Yeah, stupid question I know, but my program is displaying 1.5 sometimes, and it needs to put a 0 there, so its 1.50, but I don't know how to do this, I thought about using Round() but thats not working and I didn't see anything in the helpfile on doing this, is there a simple way of doing this? Also checked the Math UDF, didnt see anything.

-thanks R6V2

Edited by R6V2

Share this post


Link to post
Share on other sites
Jos

Yeah, stupid question I know, but my program is displaying 1.5 sometimes, and it needs to put a 0 there, so its 1.50, but I don't know how to do this, I thought about using Round() but thats not working and I didn't see anything in the helpfile on doing this, is there a simple way of doing this? Also checked the Math UDF, didnt see anything.

-thanks R6V2

Check out StringFormat()

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Swift

Thanks Jos!

Whew! This function has alot of info, it's kinda confusing!

EDIT: Hey Jos, would you mind giving me a example on how to do this, im not really understanding all the stuff in the Remarks, and all the specifications...

Edited by R6V2

Share this post


Link to post
Share on other sites
weaponx

$test = 5.1

StringFormat("%.2f", $test) ;Shows 5.10

Share this post


Link to post
Share on other sites
Swift

$test = 5.1

StringFormat("%.2f", $test) ;Shows 5.10

Aha! Thats what I was looking for, now im going to read exactly how and why it does that! Thanks WeaponX!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.