[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Problem with cents

Problem with cents

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


Posted by Ptrayal   (10 posts)  [Biography] 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
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] 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
[Go to top] top

Posted by Ptrayal   (10 posts)  [Biography] 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?
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] 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
[Go to top] 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.


11,182 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]