WTF Bites


  • Notification Spam Recipient

    @Gąska said in WTF Bites:

    @Tsaukpaetra said in WTF Bites:

    "humans reading this should instinctively know this needs to be changed"

    I don't trust people to have enough instinct to know it. And I trust the developers even less to correctly assess what is and what isn't known instinctively by the users.

    Which is why users are guided through the setup wizard, right? :tro-pop:


  • Banned

    @Tsaukpaetra yes but unironically.



  • @error said in WTF Bites:

    Seriously, Java doesn't have a primitive base-10 fractional type (like C# decimal)?

    I'm sure it's fine if I put monetary values in a double. Who cares about a few thousandths of a cent anyway? 🍹

    :um-actually: It's kinda traditional to use fixed-point arithmetic (ie BigInteger / int / long) for monetary operations anyway.

    But yes, this is one of the things that are missing in JDK, causing less... wary developers to use double :wtf: (or float for double :wtf:).


    Filed under: Actually I'm going to move them from the DB to the WS endpoint as Strings.

    This is not a bad idea, if you don't want to actually do any arithmetics.

    BigDecimal is quite slow and clunky to use, because you often need to correctly specify precision and rounding. Good for correct implementation of numeric algorithm, bad for DTO.


  • Considered Harmful

    @Kamil-Podlesak said in WTF Bites:

    use double (or float for double ).

    AIUI, the problem is that numbers such as 0.1 are infinitely repeating in base-2 (like how ⅓ is infinitely repeating in base-10), so having more precision just makes the problem less visible.


  • ♿ (Parody)

    @error said in WTF Bites:

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    Seriously, Java doesn't have a primitive base-10 fractional type (like C# decimal)?

    There's BigDecimal, that's been in there since ages ago.

    I'll try it. Hopefully both Spring Boot and MyBatis understand it.

    It's kind of annoying because all math is done through methods but it's the normal Java way to handle money.


  • Discourse touched me in a no-no place

    @error said in WTF Bites:

    @Kamil-Podlesak said in WTF Bites:

    use double (or float for double ).

    AIUI, the problem is that numbers such as 0.1 are infinitely repeating in base-2 (like how ⅓ is infinitely repeating in base-10), so having more precision just makes the problem less visible.

    Any floating point format (binary, decimal, whatever) runs into that problem. There are always rational numbers that you can't express. So you instead go to using a big rational form (ratio of two big integers) and the problem goes away. And instead you get a new one, with runaway precision (for sure if you don't normalize after every step or few). And you still can't do much more with square roots except for the ones you could do with plain integers. Fixing that (and transcendentals) takes you into really complex math territory. And is very very slow, since you'd rather not retract generated digits... 😵

    For money, just use 64-bit fixed point (with a decimal shift) with not too many fractional digits.


  • Java Dev

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    @Kamil-Podlesak said in WTF Bites:

    use double (or float for double ).

    AIUI, the problem is that numbers such as 0.1 are infinitely repeating in base-2 (like how ⅓ is infinitely repeating in base-10), so having more precision just makes the problem less visible.

    Any floating point format (binary, decimal, whatever) runs into that problem. There are always rational numbers that you can't express. So you instead go to using a big rational form (ratio of two big integers) and the problem goes away. And instead you get a new one, with runaway precision (for sure if you don't normalize after every step or few). And you still can't do much more with square roots except for the ones you could do with plain integers. Fixing that (and transcendentals) takes you into really complex math territory. And is very very slow, since you'd rather not retract generated digits... 😵

    For money, just use 64-bit fixed point (with a decimal shift) with not too many fractional digits.

    Using a rational form for money is fundamentally wrong too. You need to get the same result that you would have gotten on paper. Hence you need to apply the exact same rounding, in the exact same places, that would have been applied on paper. Not enough rounding is just as wrong as too much, or the wrong direction.


  • BINNED

    @boomzilla said in WTF Bites:

    @error said in WTF Bites:

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    Seriously, Java doesn't have a primitive base-10 fractional type (like C# decimal)?

    There's BigDecimal, that's been in there since ages ago.

    I'll try it. Hopefully both Spring Boot and MyBatis understand it.

    It's kind of annoying because all math is done through methods but it's the normal Java way to handle money.

    ☕ operator overloading is evil!


  • Discourse touched me in a no-no place

    @boomzilla said in WTF Bites:

    it's the normal Java way to handle money.

    I thought the normal Java way to handle money was to just send it to Oracle? 🎺


  • ♿ (Parody)

    @loopback0 said in WTF Bites:

    @boomzilla said in WTF Bites:

    it's the normal Java way to handle money.

    I thought the normal Java way to handle money was to just send it to Oracle? 🎺

    Hah! We switched to OpenJDK! But we still run Oracle's DB. Checkmate, us!



  • @Zerosquare said in WTF Bites:

    I don't know much about Flash, but hasn't the IDE been able to generate HTML5 for several years now?

    Adobe Animate CC 2015 (released in 2016) was the first version that included reasonable HTML5 Canvas output, though in theory they could be using features that didn't show up until later. (My guess is that they aren't,)

    It would still require development time to convert and test, so I'm sure this government entity will get started on it in, oh, 2025.



  • @Parody said in WTF Bites:

    I'm sure this government entity will get started on it in, oh, 2025.

    Now we know you're an optimist


  • 🚽 Regular

    @dkf said in WTF Bites:

    Fixing that (and transcendentals) takes you into really complex math territory

    Don't know if I see what you did there or if I'm just imagining.


  • Banned

    @PleegWat said in WTF Bites:

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    @Kamil-Podlesak said in WTF Bites:

    use double (or float for double ).

    AIUI, the problem is that numbers such as 0.1 are infinitely repeating in base-2 (like how ⅓ is infinitely repeating in base-10), so having more precision just makes the problem less visible.

    Any floating point format (binary, decimal, whatever) runs into that problem. There are always rational numbers that you can't express. So you instead go to using a big rational form (ratio of two big integers) and the problem goes away. And instead you get a new one, with runaway precision (for sure if you don't normalize after every step or few). And you still can't do much more with square roots except for the ones you could do with plain integers. Fixing that (and transcendentals) takes you into really complex math territory. And is very very slow, since you'd rather not retract generated digits... 😵

    For money, just use 64-bit fixed point (with a decimal shift) with not too many fractional digits.

    Using a rational form for money is fundamentally wrong too. You need to get the same result that you would have gotten on paper. Hence you need to apply the exact same rounding, in the exact same places, that would have been applied on paper. Not enough rounding is just as wrong as too much, or the wrong direction.

    To make matters worse, when money is involved, the right direction and the right places are usually defined by the law - which means different rounding methods in different jurisdictions. I'm so glad I don't work on finance software.


  • Discourse touched me in a no-no place

    @Zecc said in WTF Bites:

    Don't know if I see what you did there or if I'm just imagining.

    Maybe I was just tired when I wrote it.

    Math with complex numbers has its own special fun, but is only a bit harder than math with ordinary numbers, not like perfect arithmetic (which uses either special continued fractions or rank 4 tensors to construct infinite digit generators). And only Wall Street uses imaginary numbers for money so you're usually OK there.


  • Java Dev

    @Gąska said in WTF Bites:

    @PleegWat said in WTF Bites:

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    @Kamil-Podlesak said in WTF Bites:

    use double (or float for double ).

    AIUI, the problem is that numbers such as 0.1 are infinitely repeating in base-2 (like how ⅓ is infinitely repeating in base-10), so having more precision just makes the problem less visible.

    Any floating point format (binary, decimal, whatever) runs into that problem. There are always rational numbers that you can't express. So you instead go to using a big rational form (ratio of two big integers) and the problem goes away. And instead you get a new one, with runaway precision (for sure if you don't normalize after every step or few). And you still can't do much more with square roots except for the ones you could do with plain integers. Fixing that (and transcendentals) takes you into really complex math territory. And is very very slow, since you'd rather not retract generated digits... 😵

    For money, just use 64-bit fixed point (with a decimal shift) with not too many fractional digits.

    Using a rational form for money is fundamentally wrong too. You need to get the same result that you would have gotten on paper. Hence you need to apply the exact same rounding, in the exact same places, that would have been applied on paper. Not enough rounding is just as wrong as too much, or the wrong direction.

    To make matters worse, when money is involved, the right direction and the right places are usually defined by the law - which means different rounding methods in different jurisdictions. I'm so glad I don't work on finance software.

    In Dutch tax code, in many places the person filing their taxes can even decide for themselves which direction they want to round in.


  • Banned

    Hey, look! /r/KidsAreFuckingStupid! A nice, light hearted sub where you can have a good laugh at how dumb kids are and catch a break from all the political discussions going on everywhere!

    Hahaha no.

    https://www.reddit.com/r/KidsAreFuckingStupid/comments/las8x2/evolution_a_tough_concept_for_preschoolers_and/

    1. Believing in evolution, as opposed to believing in God? Seriously, what was the goal of that?
    2. It's religious preschool, not conservative preschool. So why the fucking fuck would you put "conservative" in the tilte you fuckwit!?

    I fucking hate internet.


  • Discourse touched me in a no-no place

    @Gąska said in WTF Bites:

    It's religious preschool, not conservative preschool.

    In many parts of the world, there's a substantive correlation.


  • BINNED

    @dkf said in WTF Bites:

    @Gąska said in WTF Bites:

    It's religious preschool, not conservative preschool.

    In many parts of the world, there's a substantive correlation.

    In the US, which insofar as I'm aware is the only place that uses the term "preschool," it's not a good correlation at all. There are prominent Christian denominations whose teachings emphasize the parts of Christ's teachings that line up with what The Left teaches. Some of those denominations run preschools.


  • Banned

    @dkf said in WTF Bites:

    @Gąska said in WTF Bites:

    It's religious preschool, not conservative preschool.

    In many parts of the world, there's a substantive correlation.

    By many parts of the world you mean USA? :half-trolling:


  • Considered Harmful

    @topspin said in WTF Bites:

    @boomzilla said in WTF Bites:

    @error said in WTF Bites:

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    Seriously, Java doesn't have a primitive base-10 fractional type (like C# decimal)?

    There's BigDecimal, that's been in there since ages ago.

    I'll try it. Hopefully both Spring Boot and MyBatis understand it.

    It's kind of annoying because all math is done through methods but it's the normal Java way to handle money.

    ☕ operator overloading is evil!

    Operator overloading is evil, but it shouldn't need operator overloading, because there should be a primitive type where the builtin operators work.


  • BINNED

    @error said in WTF Bites:

    @topspin said in WTF Bites:

    @boomzilla said in WTF Bites:

    @error said in WTF Bites:

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    Seriously, Java doesn't have a primitive base-10 fractional type (like C# decimal)?

    There's BigDecimal, that's been in there since ages ago.

    I'll try it. Hopefully both Spring Boot and MyBatis understand it.

    It's kind of annoying because all math is done through methods but it's the normal Java way to handle money.

    ☕ operator overloading is evil!

    Operator overloading is evil, but it shouldn't need operator overloading, because there should be a primitive type where the builtin operators work.

    This implies that either the language should ship everything anyone could reasonably think of or you lack the idea for other use cases besides this one you just clearly stumbled upon.


  • Discourse touched me in a no-no place

    @topspin The problem with operator overloading is that it is difficult to actually get right, so when it is done it is usually done wrongly, and you instead end up with substantive amounts of code use hidden almost in plain sight. (C++ makes it worse by allowing some things to be operators that probably shouldn't be, but that's nobody else's fault.) Java's approach is simply to firmly reject overloading entirely except for a very few system-defined types; you want to use custom operators without a special preprocessing step in your build? Well, tough shit. Computer Language designer says No.


  • Considered Harmful

    @topspin said in WTF Bites:

    @error said in WTF Bites:

    @topspin said in WTF Bites:

    @boomzilla said in WTF Bites:

    @error said in WTF Bites:

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    Seriously, Java doesn't have a primitive base-10 fractional type (like C# decimal)?

    There's BigDecimal, that's been in there since ages ago.

    I'll try it. Hopefully both Spring Boot and MyBatis understand it.

    It's kind of annoying because all math is done through methods but it's the normal Java way to handle money.

    ☕ operator overloading is evil!

    Operator overloading is evil, but it shouldn't need operator overloading, because there should be a primitive type where the builtin operators work.

    This implies that either the language should ship everything anyone could reasonably think of or you lack the idea for other use cases besides this one you just clearly stumbled upon.

    Oh, that obscure concept called money. Who could have anticipated such a niche requirement?


  • Considered Harmful

    @dkf said in WTF Bites:

    @topspin The problem with operator overloading is that it is difficult to actually get right, so when it is done it is usually done wrongly, and you instead end up with substantive amounts of code use hidden almost in plain sight. (C++ makes it worse by allowing some things to be operators that probably shouldn't be, but that's nobody else's fault.) Java's approach is simply to firmly reject overloading entirely except for a very few system-defined types; you want to use custom operators without a special preprocessing step in your build? Well, tough shit. Computer Language designer says No.

    It used to bug me that C++ streams changed the semantics of bitwise left- and right-shift to be stream insertion and extraction, and all the entry level CS classes failed to mention the default behavior of these operators.


    Filed under: Now the entire language bugs me.


  • Banned

    @error said in WTF Bites:

    @dkf said in WTF Bites:

    @topspin The problem with operator overloading is that it is difficult to actually get right, so when it is done it is usually done wrongly, and you instead end up with substantive amounts of code use hidden almost in plain sight. (C++ makes it worse by allowing some things to be operators that probably shouldn't be, but that's nobody else's fault.) Java's approach is simply to firmly reject overloading entirely except for a very few system-defined types; you want to use custom operators without a special preprocessing step in your build? Well, tough shit. Computer Language designer says No.

    It used to bug me that C++ streams changed the semantics of bitwise left- and right-shift to be stream insertion and extraction, and all the entry level CS classes failed to mention the default behavior of these operators.

    Scala solved that problem by allowing the programmer to create arbitrary new operators.

    Yes, I'm being sarcastic.


  • ♿ (Parody)

    @error said in WTF Bites:

    @topspin said in WTF Bites:

    @boomzilla said in WTF Bites:

    @error said in WTF Bites:

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    Seriously, Java doesn't have a primitive base-10 fractional type (like C# decimal)?

    There's BigDecimal, that's been in there since ages ago.

    I'll try it. Hopefully both Spring Boot and MyBatis understand it.

    It's kind of annoying because all math is done through methods but it's the normal Java way to handle money.

    ☕ operator overloading is evil!

    Operator overloading is evil, but it shouldn't need operator overloading, because there should be a primitive type where the builtin operators work.

    How many languages have a primitive decimal type? I assume it doesn't happen because the common hardware used today only supports integers and floating point.


  • Banned

    @boomzilla said in WTF Bites:

    @error said in WTF Bites:

    @topspin said in WTF Bites:

    @boomzilla said in WTF Bites:

    @error said in WTF Bites:

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    Seriously, Java doesn't have a primitive base-10 fractional type (like C# decimal)?

    There's BigDecimal, that's been in there since ages ago.

    I'll try it. Hopefully both Spring Boot and MyBatis understand it.

    It's kind of annoying because all math is done through methods but it's the normal Java way to handle money.

    ☕ operator overloading is evil!

    Operator overloading is evil, but it shouldn't need operator overloading, because there should be a primitive type where the builtin operators work.

    How many languages have a primitive decimal type?

    .NET has. Count it as however many languages you want.



  • @error said in WTF Bites:

    Oh, that obscure concept called money. Who could have anticipated such a niche requirement?

    I can probably count the number of times I've worked on anything involving computations with monetary units on a single hand.


  • Considered Harmful

    Reading the Jenkins console log for this build job. There's a download progress bar in the logs that wrote a line for each kilobyte downloaded.


  • Notification Spam Recipient

    @error said in WTF Bites:

    Reading the Jenkins console log for this build job. There's a download progress bar in the logs that wrote a line for each kilobyte downloaded.

    Say what? It didn't detect that it was not an interactive terminal and adjust accordingly?
    Imagine if it was outputting to a real TTY!


  • Considered Harmful

    @Tsaukpaetra said in WTF Bites:

    @error said in WTF Bites:

    Reading the Jenkins console log for this build job. There's a download progress bar in the logs that wrote a line for each kilobyte downloaded.

    Say what? It didn't detect that it was not an interactive terminal and adjust accordingly?
    Imagine if it was outputting to a real TTY!

    I don't have enough cyan for that!



  • @boomzilla said in WTF Bites:

    I assume it doesn't happen because the common hardware used today only supports integers and floating point.

    x86-64 processors still support BCD operations, although only in legacy (not 64-bit) modes.


  • Considered Harmful

    Java is, of course, strongly tied to hardware support. 🍹



  • @cvi said in WTF Bites:

    I can probably count the number of times I've worked on anything involving computations with monetary units on a single hand.

    The fact that you're still counting on your hands is probably the reason you're not involved in monetary computations 🍹


  • Notification Spam Recipient

    @HardwareGeek said in WTF Bites:

    only in legacy

    How long until processors are built that don't have the original x86-spec instructions, but only the 64-bit extensions?


  • Considered Harmful

    @Tsaukpaetra said in WTF Bites:

    @HardwareGeek said in WTF Bites:

    only in legacy

    How long until processors are built that don't have the original x86-spec instructions, but only the 64-bit extensions?

    ISTR an article posted semi-recently about how "low level" languages like C don't actually reflect how modern processors work any more.


    Filed under: Old processors holding back old languages holding back new processors...


  • BINNED

    @error said in WTF Bites:

    @Tsaukpaetra said in WTF Bites:

    @error said in WTF Bites:

    Reading the Jenkins console log for this build job. There's a download progress bar in the logs that wrote a line for each kilobyte downloaded.

    Say what? It didn't detect that it was not an interactive terminal and adjust accordingly?
    Imagine if it was outputting to a real TTY!

    I don't have enough cyan for that!

    :iunderstoodthatreference.mp4:

    Filed under: well, it was my thread


  • BINNED

    @HardwareGeek said in WTF Bites:

    @boomzilla said in WTF Bites:

    I assume it doesn't happen because the common hardware used today only supports integers and floating point.

    x86-64 processors still support BCD operations, although only in legacy (not 64-bit) modes.

    As far as I understand it, that’s just integers with “decimal” digit encoding instead of binary (one decimal digit per byte, or two in compressed form), but not “decimal” as used in fixed point math for rationals. I guess you could still use it by simply semantically counting cents instead of dollars (that’s basically a form of fixed point), but that’s how you’d reasonably deal with money anyway.


  • Discourse touched me in a no-no place

    @error said in WTF Bites:

    ISTR an article posted semi-recently about how "low level" languages like C don't actually reflect how modern processors work any more.

    I believe I may have interacted with its author a few times; they were also asserting that assembly isn't low level. My regard for them dropped like a stone at that point. We don't do CPUs out of reconfigurable hardware, and not everything even has microcode.


  • Considered Harmful

    @cvi said in WTF Bites:

    @error said in WTF Bites:

    Oh, that obscure concept called money. Who could have anticipated such a niche requirement?

    I can probably count the number of times I've worked on anything involving computations with monetary units on a single hand.

    Do you round up or down?


  • BINNED

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    ISTR an article posted semi-recently about how "low level" languages like C don't actually reflect how modern processors work any more.

    I believe I may have interacted with its author a few times; they were also asserting that assembly isn't low level. My regard for them dropped like a stone at that point. We don't do CPUs out of reconfigurable hardware, and not everything even has microcode.

    I'm pretty sure @pie_flavor posted something along those lines in the PerlRaku is insane thread, or somewhere like that :arrows:. He did have a point.



  • @TimeBandit said in WTF Bites:

    The fact that you're still counting on your hands is probably the reason you're not involved in monetary computations

    Not so sure about that one. From what I've seen, people in the finance industry would do very well if they were to master basics skills like that one.



  • @Applied-Mediocrity said in WTF Bites:

    Do you round up or down?

    Towards the middle finger. 🍹


  • BINNED

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    ISTR an article posted semi-recently about how "low level" languages like C don't actually reflect how modern processors work any more.

    I believe I may have interacted with its author a few times; they were also asserting that assembly isn't low level. My regard for them dropped like a stone at that point. We don't do CPUs out of reconfigurable hardware, and not everything even has microcode.

    I might be :whoosh:ing here, but for architectures where microcode is a thing, the assembly isn't very low level, is it?



  • @dkf said in WTF Bites:

    they were also asserting that assembly isn't low level. My regard for them dropped like a stone at that point.

    They do have a point with that IMO, at the very least in the x86 world. x86(_64) assembly is quite far away from the instructions that the various execution units actually see. There's an entire front-end dedicated to decoding x86 machine code and translating it to the microcode for the later stages.

    Edit: :hanzo:d.


  • Considered Harmful

    But does it matter? There is no way for anyone to run general purpose programs that are even more fine grained than raw assembly on x86-64 computers. Assembly is "close to metal" as one can get.

    The re-definition of low-level being exactly the calculations that CPU actually does is tedious tecknical high-falutin of no practical consequence 😑



  • @Applied-Mediocrity said in WTF Bites:

    tedious tecknical high-falutin of no practical consequence

    Welcome to TDWTF.



  • @Tsaukpaetra National Semiconductor has one. It boots directly to 64-bit protected mode, with no support for real mode or v86 mode. No idea why though: it's intended for embedded applications as a system-on-a-chip, with most pins intended to feed directly into various PHYs, and because of that it has fewer address lines than a normal 32-bit chip, not more.


  • ♿ (Parody)

    @GuyWhoKilledBear said in WTF Bites:

    @dkf said in WTF Bites:

    @error said in WTF Bites:

    ISTR an article posted semi-recently about how "low level" languages like C don't actually reflect how modern processors work any more.

    I believe I may have interacted with its author a few times; they were also asserting that assembly isn't low level. My regard for them dropped like a stone at that point. We don't do CPUs out of reconfigurable hardware, and not everything even has microcode.

    I might be :whoosh:ing here, but for architectures where microcode is a thing, the assembly isn't very low level, is it?

    "Low" is kind of a relative term in this context, so you could be both right and wrong depending on how it's being used.


Log in to reply