Hi All,
I am working with currencies and would like both to display them in fixed format (currency symbol, padding and fixed decimal places), and perform math on them.
Obviously I can just defer formatting until the very last minute when I need to display, but I also do a lot of work in Dataset[], so it would be great if I could apply formatting to the currency values at the point I build the Dataset, without losing the ability to to total, average, and so on, in the Dataset. Then my currency values are formatted the way I want them throughout the application.
In terms of the formatting, NumberForm[] seemed to do the trick, but then I can only perform math on them using a very inelegant Part[] kludge.
For example...
nums = NumberForm[Quantity[#, "£"], {5, 2}, DigitBlock -> 3,
NumberSeparator -> ",", NumberPadding -> {" ", "0"}] & /@ {123.5,
100.57, 56.1}
Gets me my currencies formatted exactly as I want them.
But then an operation like addition fails...
nums[[1]] + nums[[2]]
...as it simply concatenates the strings.
This works...
nums[[1, 1]] + nums[[2, 1]]
But is dreadfully inelegant, and will mean a lot of fiddly work to perform math on Datasets.
Any suggestions?
Thanks in advance
Brad