It’s easier to just compute the smallest atomic amount of a currency, usually cents, using integers. Then display it as full dollars, pounds, euros—what have you—to the end user. For Division you need some way to account for the remainder across transactions, but that’s probably rules from accounting and not integer math.
What’s the benefit of Dinero? Is that like the financial equivalent of the iseven() dependency?
JavaScript is a bit funny and doesn’t actually have native integers… every number is a floating point, which means even whole number math gets weird sometimes. Not often, but enough that cents were lost and people were upset.
I haven’t looked at how Dinero works under the hood, but I never had any problems at all with it after we started using it. Front end works in cents, back end works in decimal, is what I’d suggest for anyone else reading this. Statically typed languages are much easier to control and you don’t need a library at all if you’re careful.
I don’t know how people deal with JavaScript. It’s like it was made for rapidly making shitty canoes out of tarps and duct tape for the early internet, and now you’re expected to build deep sea submersibles with reinforced tarps and extra-strong duct tape. Wtf…
Yeah… I like the syntax, but I hate the old jank. Still one of my favourite languages regardless. But definitely your first year will be variations of “why does JavaScript do that” 😂 I damn near quit when I had to do timezone and scheduling stuff with native date objects
Btw I’m not the one downvoting you someone else is. And yeah it sounds like an entirely different beast from normal programming almost like memory constrained embedded programming is its own beast.
Lol that makes a lot of sense now! I thought you had a hate stalker downvoting every new comment you make which seems to be a thing on Lemmy for some reason.
It’s easier to just compute the smallest atomic amount of a currency, usually cents, using integers. Then display it as full dollars, pounds, euros—what have you—to the end user. For Division you need some way to account for the remainder across transactions, but that’s probably rules from accounting and not integer math.
What’s the benefit of Dinero? Is that like the financial equivalent of the iseven() dependency?
JavaScript is a bit funny and doesn’t actually have native integers… every number is a floating point, which means even whole number math gets weird sometimes. Not often, but enough that cents were lost and people were upset.
I haven’t looked at how Dinero works under the hood, but I never had any problems at all with it after we started using it. Front end works in cents, back end works in decimal, is what I’d suggest for anyone else reading this. Statically typed languages are much easier to control and you don’t need a library at all if you’re careful.
That’s cursed.
I don’t know how people deal with JavaScript. It’s like it was made for rapidly making shitty canoes out of tarps and duct tape for the early internet, and now you’re expected to build deep sea submersibles with reinforced tarps and extra-strong duct tape. Wtf…
Yeah… I like the syntax, but I hate the old jank. Still one of my favourite languages regardless. But definitely your first year will be variations of “why does JavaScript do that” 😂 I damn near quit when I had to do timezone and scheduling stuff with native date objects
Btw I’m not the one downvoting you someone else is. And yeah it sounds like an entirely different beast from normal programming almost like memory constrained embedded programming is its own beast.
I remove my own default upvote from my comments because I’m a weirdo
Lol that makes a lot of sense now! I thought you had a hate stalker downvoting every new comment you make which seems to be a thing on Lemmy for some reason.
I do also have those, but they got bored and lost interest. They do still occasionally get triggered by my username though 😂