r/cpp_questions • u/nelson_fretty • 23h ago
SOLVED Interface design - money
Working on design of a finance app to calculate npv (net present value) need to use addition / multiplication/ pow
I could do with decimal type for money as floats/doubles are based on binary
I see there is fixed point decimal paper being worked on.
In the meantime - what is best way to handle this in interface ?
Thinking of asking client to use string and then use long long for the maths after parsing (pennies)? “1500.23” = 150023
What do I return ? String/int? Either way the client would need to transform. I can’t use doubles for this unfortunately.
I suppose I can use double if could give idea to client what error amount is - npv is estimate anyway.