Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Problem with cents

Problem with cents

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Ptrayal   (10 posts)  Bio
Date Fri 18 Nov 2011 04:45 PM (UTC)
Message
Hello:
I'm having a problem with my dollars and cents. I'm using KaVir's generic plugin as a my base and I've hit a snag.

If I have 12 cents, it shows fine. It's when I get to single cents that it is displaying things like $10.9, not $10.09. Anyone have any thoughts on how to fix this problem?

Best Regards,
Rayal
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #1 on Fri 18 Nov 2011 04:55 PM (UTC)

Amended on Fri 18 Nov 2011 05:00 PM (UTC) by Fiendish

Message
string.format("%02d",your_cents_variable)

This means "2 digits with 0s filling the rest of the space".
See http://www.cplusplus.com/reference/clibrary/cstdio/printf/ for a string.format quick reference.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Ptrayal   (10 posts)  Bio
Date Reply #2 on Fri 18 Nov 2011 05:00 PM (UTC)
Message
Fiendish said:


string.format("%02d",your_cents_variable)

This means "2 digits with 0s filling the rest of the space".
See http://www.cplusplus.com/reference/clibrary/cstdio/printf/
for a string.format quick reference.

In the plugin or in my code?
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #3 on Fri 18 Nov 2011 05:01 PM (UTC)

Amended on Fri 18 Nov 2011 05:02 PM (UTC) by Fiendish

Message
Ptrayal said:

Fiendish said:


string.format("%02d",your_cents_variable)

This means "2 digits with 0s filling the rest of the space".
See http://www.cplusplus.com/reference/clibrary/cstdio/printf/
for a string.format quick reference.

In the plugin or in my code?

You haven't posted either. How am *I* supposed to know? I'm just telling you the general solution to the problem of wanting zero-padded numbers.

https://github.com/fiendish/aardwolfclientpackage
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,408 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.