| Post Reply | RetroFed Forum Forum Index » Science Memes |
| Author | Message | ||
|---|---|---|---|
cannedtuna
lemmy.world
cannedtuna@lemmy.worldJoined: 2023-06-21 |
|
||
| 831 Original | |||
|
Unleaded8163
fedia.io
Unleaded8163@fedia.io Joined: 2023-09-12 |
But... they are fractions. |
||
| 14 | |||
|
NeatNit
discuss.tchncs.de
NeatNit@discuss.tchncs.de Joined: 2024-01-05 |
But... they are fractions.
They are fractions of the format m/(2^n), but they only mimic fractions like 2/5. |
||
| 50 | |||
|
djmikeale
feddit.dk
djmikeale@feddit.dk Joined: 2025-06-24 |
But... they are fractions.
I guess op refers to how they're represented which is a bit complex imo: https://www.geeksforgeeks.org/digital-logic/floating-point-representation-basics/ |
||
| 19 | |||
mercano
lemmy.world
mercano@lemmy.worldJoined: 2023-06-18 |
If you need actual numerators and denominators, there are libraries for that. |
||
| 12 | |||
|
Quetzalcutlass
lemmy.world
Quetzalcutlass@lemmy.world Joined: 2023-08-02 |
I feel obligated to post a link to this excellent (albeit incomplete) writeup of posits and unums, which can more accurately represent common fractions in memory at the same (or lower) bit size compared to traditional floating point. Said page also includes the single best slightly-above-entry-level explanation of how floating point works I've ever seen. |
||
| 59 | |||
|
terranoid
lemmy.cafe
terranoid@lemmy.cafe Joined: 2026-05-08 |
I feel obligated to post a link to this excellent (albeit incomplete) writeup of posits and unums, which can more accurately represent common fractions in memory at the same (or lower) bit size compared to traditional floating point. Said page also includes the single best slightly-above-entry-level explanation of how floating point works I've ever seen.
i have so many protocols to represent the most common fractions perfectly without needing more than just ONE bit. They even work with positive and negative infinity! The trick is to first negotiate the protocol youre using. protocol schema 1/2 1 bit, little endian if one: value is exactly 1/2 If zero: value is NOT one half Schema 1/3 if one: value is 1/3 |
||
| 21 | |||
|
Quetzalcutlass
lemmy.world
Quetzalcutlass@lemmy.world Joined: 2023-08-02 |
If you need actual numerators and denominators, there are libraries for that.
Ah, Apache Commons: for those who felt Java's standard library wasn't bloated enough already. (I kid, I kid, though it was always funny just how many basic features seemed to be missing from Java back in the day despite its massive bundled library, leading to seemingly every major project adding Commons as a dependency. Not as much as thing these days AFAIK) |
||
| 4 | |||
|
Quetzalcutlass
lemmy.world
Quetzalcutlass@lemmy.world Joined: 2023-08-02 |
i have so many protocols to represent the most common fractions perfectly without needing more than just ONE bit. They even work with positive and negative infinity! The trick is to first negotiate the protocol youre using. protocol schema 1/2 1 bit, little endian if one: value is exactly 1/2 If zero: value is NOT one half Schema 1/3 if one: value is 1/3
I've managed to create a compression algorithm that reduces files down to a single bit. I call it "is this file 'loss.png'?". It's guaranteed 100% lossless with any input! |
||
| 36 | |||
|
yucandu
lemmy.world
yucandu@lemmy.world Joined: 2025-03-12 |
I had to just emulate floating points to save pulling in the giant print float library in stm32 to save flash memory. And then I learned that's what all the pros do IRL anyway. |
||
| 14 | |||
|
sculptor0725
sh.itjust.works
sculptor0725@sh.itjust.works Joined: 2026-07-16 |
They are fractions of the format m/(2^n), but they only mimic fractions like 2/5.
That's 2¹/5 to you! |
||
| 8 | |||
|
nemopy
lemmy.zip
nemopy@lemmy.zip Joined: 2026-06-27 |
This is peak humor |
||
| 35 | |||
|
Unpigged
lemmy.dbzer0.com
Unpigged@lemmy.dbzer0.com Joined: 2023-11-14 |
The joke missed opportunity to have two ints |
||
| 20 | |||
|
Kairos
lemmy.today
LodeMike@lemmy.today Joined: 2023-12-26 |
The joke missed opportunity to have two ints
Floats aren't fractions. Use a rational number library if you actually need a fraction. |
||
| 12 | |||
|
LurkingLuddite
piefed.social
LurkingLuddite@piefed.social Joined: 2026-02-04 |
I feel obligated to post a link to this excellent (albeit incomplete) writeup of posits and unums, which can more accurately represent common fractions in memory at the same (or lower) bit size compared to traditional floating point. Said page also includes the single best slightly-above-entry-level explanation of how floating point works I've ever seen.
Isn't a big point of floating point that it can easily have mathematical operators done on them on CPUs? Sure, complex circuitry is no big deal these days, but IIRC, there were very good reasons for what was chosen. |
||
| 7 | |||
|
Quetzalcutlass
lemmy.world
Quetzalcutlass@lemmy.world Joined: 2023-08-02 |
Isn't a big point of floating point that it can easily have mathematical operators done on them on CPUs? Sure, complex circuitry is no big deal these days, but IIRC, there were very good reasons for what was chosen.
One of the linked papers makes the claim that the circuitry would be less complex than that needed for floats, but also includes this note:
The proposed system also lacks NaN and separate positive/negative infinities, so it wouldn't be a drop-in replacement. |
||
| 14 | |||
|
floquant
lemmy.dbzer0.com
floquant@lemmy.dbzer0.com Joined: 2024-05-31 |
Floats aren't fractions. Use a rational number library if you actually need a fraction.
Isn't this a looks inside floating point binary representation in memory situation? |
||
| 9 | |||
Anafabula
discuss.tchncs.de
Anafabula@discuss.tchncs.deJoined: 2023-06-10 |
I've managed to create a compression algorithm that reduces files down to a single bit. I call it "is this file 'loss.png'?". It's guaranteed 100% lossless with any input!
Reminds me of MetaGolfScript. |
||
| 3 | |||
|
VinegarChunks
lemmus.org
VinegarChunks@lemmus.org Joined: 2026-02-20 |
I had to just emulate floating points to save pulling in the giant print float library in stm32 to save flash memory. And then I learned that's what all the pros do IRL anyway.
I am hard pressed to find anyone irl who would be impressed by this but I made a spreadsheet that converts hexadecimal into float using only standard excel formulas. |
||
| 6 | |||
|
Zarobi
aussie.zone
Zarobi@aussie.zone Joined: 2026-06-23 |
i have so many protocols to represent the most common fractions perfectly without needing more than just ONE bit. They even work with positive and negative infinity! The trick is to first negotiate the protocol youre using. protocol schema 1/2 1 bit, little endian if one: value is exactly 1/2 If zero: value is NOT one half Schema 1/3 if one: value is 1/3
Can you explain how this works exactly? Do you mean you have like a "third type" or "fraction": 3 and you just store 00 for 0/3, 01 for 1/3, 10 for 2/3, 11 for 3/3? If it's an object, struct, or class type to store the context, then it's not a primative and has a lot of overhead for arithmetic and I don't see how you could possibly even do simple things like 1/3 + 2/6 |
||
| 2 | |||
|
Zarobi
aussie.zone
Zarobi@aussie.zone Joined: 2026-06-23 |
I feel obligated to post a link to this excellent (albeit incomplete) writeup of posits and unums, which can more accurately represent common fractions in memory at the same (or lower) bit size compared to traditional floating point. Said page also includes the single best slightly-above-entry-level explanation of how floating point works I've ever seen.
As far as I understand, it seems to sacrifice accuracy at larger numbers, for more accuracy at smaller numbers. As they say, that seems like a reasonable tradeoff, because we tend to mostly use smaller numbers in our software. In my honest opinion though, if accuracy is a concern, I reach for decimal or integer based mathematical libraries. For example, in a JavaScript project that needed to handle currency, I used Dinero, because $0.1 + $0.2 needs to actually work properly. As far as I understand, it just does all math in integers, and then you can display it as a string in the UI or export it as an integer for storage as a realised decimal in the database. |
||
| 6 | |||
Destide
feddit.uk
sirico@feddit.ukJoined: 2023-07-04 |
There are two types of c# Devs |
||
| 1 | |||
|
Unpigged
lemmy.dbzer0.com
Unpigged@lemmy.dbzer0.com Joined: 2023-11-14 |
Floats aren't fractions. Use a rational number library if you actually need a fraction.
Why you tell me this? |
||
| 5 | |||
|
Kairos
lemmy.today
LodeMike@lemmy.today Joined: 2023-12-26 |
Why you tell me this?
I don't know. It felt better to bring it up here than replying to the post, I think. |
||
| 2 | |||
|
Quibblekrust
thelemmy.club
Quibblekrust@thelemmy.club Joined: 2025-02-09 |
Can you explain how this works exactly? Do you mean you have like a "third type" or "fraction": 3 and you just store 00 for 0/3, 01 for 1/3, 10 for 2/3, 11 for 3/3? If it's an object, struct, or class type to store the context, then it's not a primative and has a lot of overhead for arithmetic and I don't see how you could possibly even do simple things like 1/3 + 2/6
|
||
| 3 | |||
|
iocase
lemmy.zip
iocase@lemmy.zip Joined: 2026-05-11 |
As far as I understand, it seems to sacrifice accuracy at larger numbers, for more accuracy at smaller numbers. As they say, that seems like a reasonable tradeoff, because we tend to mostly use smaller numbers in our software. In my honest opinion though, if accuracy is a concern, I reach for decimal or integer based mathematical libraries. For example, in a JavaScript project that needed to ha...
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? |
||
| 3 | |||
|
Zarobi
aussie.zone
Zarobi@aussie.zone Joined: 2026-06-23 |
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 th...
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. |
||
| 3 | |||
|
iocase
lemmy.zip
iocase@lemmy.zip Joined: 2026-05-11 |
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 dec...
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... |
||
| 1 | |||
|
Zarobi
aussie.zone
Zarobi@aussie.zone Joined: 2026-06-23 |
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 |
||
| 2 | |||
|
iocase
lemmy.zip
iocase@lemmy.zip Joined: 2026-05-11 |
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. |
||
| 2 | |||
|
Zarobi
aussie.zone
Zarobi@aussie.zone Joined: 2026-06-23 |
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 |
||
| 1 | |||
|
iocase
lemmy.zip
iocase@lemmy.zip Joined: 2026-05-11 |
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. |
||
| 2 | |||
|
Zarobi
aussie.zone
Zarobi@aussie.zone Joined: 2026-06-23 |
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 😂 |
||
| 2 | |||
| Post Reply |
Back to top |