Formatting a float to currency

2022-09-24 Thread leidalinck
Unfortunately, hardly many bookmakers now provide profitable wagers on cybersports. I have been playing on loki casino mobile for a very long time. I would strongly advise checking at the URL I provided above if you're seeking for a reputable bookmaker with a big selection of well-liked games.

Formatting a float to currency

2021-06-29 Thread timothee
> But the code is pretty bad, both slow and hard to understand.. it can be improved during code review; at least it seems more correct than which I kept breaking during code review

Formatting a float to currency

2021-06-28 Thread Araq
> I like it; would you consider writing a PR against nim repo ? (refs > ) Oh er... But the code is pretty bad, both slow and hard to understand...

Formatting a float to currency

2021-06-28 Thread timothee
> I was referring to the output of the function, once the float number is > converted to string. still, the sign is useful to have in output (but ok to have option to omit it for 0) > very remote case, not sure if it's really necessary... if this impacts performance, it's not worth it, but it

Formatting a float to currency

2021-06-28 Thread Javi
> the sign is useful, eg: I was referring to the output of the function, once the float number is converted to string. Example: fmtFloat(-0.0, 2) == "0.00" Run > decimalSep: should be char, not string Yes, I was going to use chars for the separators but I used strin

Formatting a float to currency

2021-06-28 Thread timothee
> Maybe it could be a good idea never include the sign when the value is 0 (?). the sign is useful, eg: 1/-0.0 = -Inf 1/0.0 = Inf

Formatting a float to currency

2021-06-28 Thread Javi
Hi, > I like it; would you consider writing a PR against nim repo refs > ) there's a few things I > would change in the API but it could be addressed in code review. Sure, no problem at all. > also, this case fails: doAssert fmtFloat(-0.0, 1, "t"

Formatting a float to currency

2021-06-28 Thread xflywind
see also

Formatting a float to currency

2021-06-28 Thread enthus1ast
I think for this special libraries should be used, like winapi (maybe GetCurrencyFormatW ) or gnu gettext.

Formatting a float to currency

2021-06-28 Thread digitalcraftsman
The API is indeed a bit "English-centric". The documentation for [strutils.formatFloat()](https://nim-lang.org/docs/strutils.html#formatFloat%2Cfloat%2CFloatFormatMode%2Crange%5B%5D%2Cchar) allows the user to specify the separator between the integer and rational part of a number via the `decima

Formatting a float to currency

2021-06-27 Thread xigoi
The proposed API feels too English-centric. For example, how would you produce numbers in Indian format (12,34,56,789.0)?

Formatting a float to currency

2021-06-27 Thread timothee
I like it; would you consider writing a PR? there's a few things I would change in the API but it could be addressed in code review. also, this case fails: doAssert fmtFloat(-0.0, 1, "t") == "-0.0" Run you can use math.signbit, or better, factor out the 1st part wi

Formatting a float to currency

2021-06-27 Thread Javi
I do this: import math import strformat # -- proc fmtFloat*(value: float, decimals: int, format: string = ""): string = if value != value:

Formatting a float to currency

2021-06-27 Thread timothee
see previous attempt here: I still think this would be a useful API, but a new proposal should use the discussions in that PR into account.

Formatting a float to currency

2021-06-27 Thread xigoi
Be very careful with this because different languages format numbers in different ways. If your project is meant to be international, you'll have to use a library.

Formatting a float to currency

2021-06-27 Thread jasonfi
Thanks! I was sure someone else had this problem before. I'll try it out.

Formatting a float to currency

2021-06-27 Thread lscrd
`insertSep` from module `strutils` is able to insert separators, but it doesn’t work well with floats: import strutils echo ($12345.67).insertSep(',')# 12,345,.67. Run So we have to do some work to get the right result: import strutils var s =

Formatting a float to currency

2021-06-27 Thread jasonfi
I want to format a float, e.g. 12345.67 to a string as if it were a currency, e.g. "12,345.67". Is there a standard way of doing this with Nim?