Little bit of everything!

Avid Swiftie (come join us at !taylorswift@poptalk.scrubbles.tech )

Gaming (Mass Effect, Witcher, and too much Satisfactory)

Sci-fi

I live for 90s TV sitcoms

  • 216 Posts
  • 2.32K Comments
Joined 1 year ago
cake
Cake day: June 2nd, 2023

help-circle

  • Correct, JSON can handle any precision, because it’s just dumped as a string anyway, just not enclosed in the "". However, as you mentioned, as soon as it comes through the parser it’ll put it into an underlying float value. In C# I create a save high precision attribute that will take the value and put it directly into a decimal. In JS I’m sure there’s some way to do that, but that parser is way less extensible compared to C#. However, this also all assumes you know the client will parse it correctly, overriding the default behavior. Safest is to just send it as a string, and then create your parsers to automatically send to and from strings



  • The fun differences between the perfect world of theoretical and the realistic. Everyone thinks of computers as perfect - but it’s not until you’re asked to solve “How do you store decimals using only 0s and 1s?” does it start to click. Not as easy. It’s why I’m hesitant to hire bootcampers into my roles. Bootcamps are great, and they get more people coding, but you don’t learn that theory behind the scenes - you don’t really know what the computer and operating systems are doing. For 90% of the time it doesn’t matter, it’s abstracted away - but that last 10% man, that can really fuck up an entire system.


  • Long and short, floating point math is imprecise, and when dealing with currency you must be 100% precise. One of those rules of programming: Never store (or let currency flow through) a float. That includes doubles too.

    In javascript, the number type is imprecise, it is contained by a float under the hood, meaning precision can be lost. So even just parsing JSON to a number, even if you mean to move it into something like BigNumber, the precision is already not guaranteed when it finally gets to BigNumber. The safest thing to do is pass the numeric values as strings, which are guaranteed of course to represent their exact precision and value, and then use a proper precise parser to the value, like BigNumber.parse(strValue). (Even then, there’s an argument that it’s very rare that you ever need an amount outside of a string in a UI. Most calculations should be handled by a server that’s the single source of truth in calculations, think sales tax and shipping, so a string is just a value that is presented to a user).

    In C#, float and double are imprecise and not guaranteed, especially with arithmetic. Decimal is the best way to store an exact value.

    In databases, it’s usually best practice to store the string value of the amount for exact precise recordkeeping, with a decimal field next to it labeled something like AmountImprecise that you can use for aggregating, sorting, grouping, whatever.

    Every language will have it’s quirks, but essentially, take this from me, a senior fintech engineer. If you see currency amounts, think precision, and know you’ll need to take extra extra care about how it’s stored. You don’t want to accidentally office space yourself, especially when auditors come around.









  • I know it’s weird here on the fediverse, but I’ve been through it. If you want, DM me anytime, or DM me and I can give my mastodon. Should probably start a community sometime. It’s been good talking to you too!

    I wish you luck, but be prepared for anger in response. Just be ready for it. Make it not about the politics but instead the hate, the anger. Hell try to make it about politics but instead make it about the hate. It’s not about Biden or trump, it’s the anger.







  • Which is why as an engineer I can either riddle with a prompt for half an hour… Or just write the damn method myself. For juniors it’s an easy button, but for seniors who know how to write these algorithms it’s usually just easier to write it up. Some nice starter code though, gets the boilerplate out of the way


  • Scrubbles@poptalk.scrubbles.techtomemes@lemmy.worldAI bell curve
    link
    fedilink
    English
    arrow-up
    43
    arrow-down
    1
    ·
    6 days ago

    This was exactly my experience. Freaked myself out last year and decided best thing was to dive headfirst into it to figure out how it worked and what it’s capabilities are.

    Which - it has a lot. It can do a lot, and it’s impressive tech. Coded several projects and built my own models. But, it’s far from perfect. There are so so so many pitfalls that startups and tech evangelists just happily ignore. Most of these problems can’t be solved easily - if at all. It’s not intelligent, it’s a very advanced and unique prediction machine. The funny thing to me is that it’s still basically machine learning, the same tech that we’ve had since the mid 2000s, it’s just we have fancier hardware now. Big tech wants everyone to believe it’s brand new… and it is… kind of. But not really either.