pioneerspacesim/pioneer — pull request #2774 by impaktor (2014-02-19 19:05:57+00:00)
Title: Smarter money format

## Smarter Money Format

This removes the fractional part of money string *if* empty. If the fractional part is non-zero print with two floating digits (15.1 --> $15.10).

Unlike the current implementation, where `Format.Money(-1)` returns `$-1.00`, this one returns `-$1.00`.

It can take an optional argument for when to always print fractional part, thus behaving like the current implementation of Format.Money for values below this threshold. I've set the default to 10, -- I don't know if that is sensible, but then any number under 10, (and above -10) will always print the fractional part even if zero.

Test:

-1 --> -$1.00
1 --> $1.00
1.91 --> $1.91
9.1 --> $9.10
9.01 --> $9.01
200.1 --> $200.10
10.1 --> $10.10
11.10 --> $11.10
10.00 --> $10
10.01 --> $10.01

Fixes #1600, #133
ref #1517

![2014-02-19-092344_954x468_scrot](https://f.cloud.github.com/assets/619390/2205490/a142942c-9950-11e3-858f-3b072e496b0a.png)
![2014-02-19-092525_944x465_scrot](https://f.cloud.github.com/assets/619390/2205492/a7930c8a-9950-11e3-875d-0031a652c6c2.png)
![2014-02-19-194757_944x465_scrot](https://f.cloud.github.com/assets/619390/2210408/78257c92-9998-11e3-9e97-eb082c3f5be9.png)

## My amazing coding skills

I just looked at the code that was in place. Thus I wonder if for instance `char[32]` is enough, as that would put an upper cap on money of 10^8 (due to two chars for decimal)? Also, I really have no clue about `LuaFormat.cpp`, but with only 9 lines of code changed, I can only do so much damage I hope.