Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent currency formatting #1801

Closed
sweemer opened this issue Oct 1, 2023 · 4 comments · Fixed by #1810
Closed

Inconsistent currency formatting #1801

sweemer opened this issue Oct 1, 2023 · 4 comments · Fixed by #1810
Labels

Comments

@sweemer
Copy link
Contributor

sweemer commented Oct 1, 2023

I just happen to notice, that the format strings for some currencies are fine (like for EUR), some are wrong (like for EGP), and some result in an exception being thrown (like for NGN).

#include <ql/currencies/all.hpp>
#include <ql/money.hpp>
#include <iostream>

using namespace QuantLib;

int main() {
  Money m1 = 50000.0 * EURCurrency();
  std::cout << m1 << std::endl; // prints "EUR 50000.00"
  Money m2 = 50000.0 * EGPCurrency();
  std::cout << m2 << std::endl; // prints "1$.2f EGP"
  Money m3 = 50000.0 * NGNCurrency();
  std::cout << m3 << std::endl; // throws "boost::bad_format_string: format-string is ill-formed"
}

Is currency formatting still a supported feature? If so, then I guess all the formats should be reviewed and fixed where necessary. If not, then maybe this feature can be deprecated in 1.32 and then removed later.

I'm using clang 18 on Ubuntu 22 but I would imagine that all platforms are equally affected.

@sweemer
Copy link
Contributor Author

sweemer commented Oct 7, 2023

If no consensus, then I propose we deprecate Currency::format and remove it in a later release.

@lballabio
Copy link
Owner

Sometimes I think we should deprecate the whole Money and Currency classes, but that would be too far 😄

format can probably be deprecated.

@sweemer
Copy link
Contributor Author

sweemer commented Oct 10, 2023

OK I will take a stab at the PR

Copy link
Contributor

This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants