463
IEEE 754 (cdn.fosstodon.org)

cross-posted from: https://lemmy.ml/post/24332731

~~Stolen~~ Cross-posted from here: https://fosstodon.org/@foo/113731569632505985

top 37 comments
sorted by: hot top controversial new old
[-] Toes@ani.social 22 points 1 month ago
[-] bleistift2@sopuli.xyz 18 points 1 month ago

Well, duh. All fractions are real.

[-] jabathekek@sopuli.xyz 9 points 1 month ago

except for the imaginary ones

[-] TempermentalAnomaly@lemmy.world 4 points 1 month ago

Until you construct a square with them.

[-] bleistift2@sopuli.xyz 2 points 1 month ago* (last edited 1 month ago)

ℚ ⊂ ℝ ⊂ ℂ, at least that’s how I was taught.

[-] cyborganism@lemmy.ca 17 points 1 month ago

LOL! Man I learned that in college and never used it ever again. I never came across any scenarios in my professional career as a software engineer where knowing this was useful at all outside of our labs/homework.

Anyone got any example where this knowledge became useful?

[-] magic_lobster_party@fedia.io 48 points 1 month ago

It’s useful to know that floats don’t have unlimited precision, and why adding a very large number with a very small number isn’t going to work well.

[-] cyborganism@lemmy.ca 2 points 1 month ago

Yeah but you don't really have to think about how it works in the background ever time you deal with that. You just know.

You learn how once and then you just remember not to do that and that's it.

[-] magic_lobster_party@fedia.io 2 points 1 month ago

I agree we don’t generally need think about the technical details. It’s just good to be aware of the exponent and mantissa parts to better understand where the inaccuracies of floating point numbers come from.

[-] chevy9294@monero.town 1 points 1 month ago

And this is why f64 exists!

[-] zqwzzle@lemmy.ca 14 points 1 month ago

If you’re doing any work with accounting, or writing test cases with floating point values.

[-] tdawg@lemmy.world 16 points 1 month ago

Please tell me you aren't using floating points with money

[-] wewbull@feddit.uk 38 points 1 month ago

Knowing not to use floating point with money is good use of that knowledge.

[-] psivchaz@reddthat.com 6 points 1 month ago

You'd be dismayed to find out how often I've seen people do that.

[-] zqwzzle@lemmy.ca 4 points 1 month ago

Yeah I shudder when I see floats and currency.

[-] Womble@lemmy.world 3 points 1 month ago* (last edited 1 month ago)

Eh, if you use doubles and you add 0.000314 (just over 0.03 cents) to ten billion dollars you have an error of 1/10000 of a cent, and thats a deliberately perverse transaction. Its not ideal but its not the waiting disaster that using single precision is.

[-] SubArcticTundra@lemmy.ml 2 points 1 month ago* (last edited 1 month ago)

That sounds like an explosive duo

[-] Saleh@feddit.org 2 points 1 month ago

How do you do money? Especially with stuff like some prices having three or four decimals

[-] jmcs@discuss.tchncs.de 10 points 1 month ago

Instead of representing $1.102 as 1.102 your store it as 1012 (or whatever precision you need) and divide by 1000 only for displaying it.

[-] Saleh@feddit.org 1 points 1 month ago

So if you handle different precisions you also need to store the precision/exponent explicitly for every value. Or would you sanitise this at input and throw an exception if someone wants more precision than the program is made for?

[-] jmcs@discuss.tchncs.de 6 points 1 month ago

It depends on the requirements of your app and what programming language you use. Sometimes you can get away with using a fixed precision that you can assume everywhere, but most common programming languages will have some implementation of a decimal type with variable precision if needed, so you won't need to implement it on your own outside of university exercises.

[-] Saleh@feddit.org 2 points 1 month ago

Okay thank you. I was wondering because for stuff like buying electricity, gas or certain resources, parts etc. there is prices with higher precision in cents, but the precision would not be identical over all use cases in a large company.

[-] wewbull@feddit.uk 5 points 1 month ago

No exponent, or at least a common fixed exponent. The technique is called "fixed point" as opposed to "floating point". The rationale is always to have a known level of precision.

[-] cyborganism@lemmy.ca 1 points 1 month ago

No. I don't have to remember that.

I just have to remember the limits and how you can break the system. You don't have to think about the representation.

[-] socsa@piefed.social 6 points 1 month ago

Accumulation of floating point precision errors is so common, we have an entire page about why unit tests need to account for it.

[-] okwhateverdude@lemmy.world 5 points 1 month ago

How long has this career been? What languages? And in what industries? Knowing how floats are represented at the bit level is important for all sorts of things including serialization and math (that isn't accounting).

[-] leisesprecher@feddit.org 2 points 1 month ago

More than a surface level understanding is not necessary. The level of detail in the meme is sufficient for 99,9% of jobs.

No, that's not all just accounting, it's pretty much everyone who isn't working on very low level libraries.

What in turn is important for all sorts of things is knowing how irrelevant most things are for most cases. Bit level is not important, if you're operating 20 layers above it, just as business logic details are not important if you're optimizing a general math library.

[-] cyborganism@lemmy.ca 1 points 1 month ago

Since 2008.

I've worked as a build engineer, application developer, web developer, product support, DevOps, etc.

I only ever had to worry about the limits, but never how it works in the background.

[-] scratchee@feddit.uk 5 points 1 month ago

In game dev it’s pretty common. Lots of stuff is built on floating point and balancing quality and performance, so we can’t just switch to double when things start getting janky as we can’t afford the cost, so instead we actually have to think and work out the limits of 32 bit floats.

[-] cyborganism@lemmy.ca 1 points 1 month ago

So you have to remember how it's represented in the system with how the bits are used? Or you just have to remember some general rules that "if you do that, it'll fuck up."

[-] scratchee@feddit.uk 2 points 1 month ago

Well, rules like “all integers can be represented up to 2^24” and “10^-38 is where denormalisation happens” are helpful, but I often have to figure out why I got a dodgy value from first principles, floating point is too complicated to solve every problem with 3 general rules.

I wrote a float from string function once which obviously requires the details (intentionally low quality and limited but faster variant since the standard version was way too slow).

[-] stsquad@lemmy.ml 1 points 1 month ago

Writing floating point emulation code?

I'd pretty much avoided learning about floating point until we decided to refactor the softfloat code in QEMU to support additional formats.

[-] cyborganism@lemmy.ca 1 points 1 month ago

The very wide majority of IT professionals don't work on emulation or even system kernels. Most of us are doing simple applications, or working on supporting these applications, or their deployment and maintenance.

[-] bleistift2@sopuli.xyz 1 points 1 month ago

To not be surprised when 0.1 + 0.1 != 0.2

[-] pyre@lemmy.world 11 points 1 month ago

finally a clever user of the meme

[-] marcos@lemmy.world 1 points 1 month ago

It's not mimicry.

this post was submitted on 02 Jan 2025
463 points (98.5% liked)

Science Memes

11861 readers
2652 users here now

Welcome to c/science_memes @ Mander.xyz!

A place for majestic STEMLORD peacocking, as well as memes about the realities of working in a lab.



Rules

  1. Don't throw mud. Behave like an intellectual and remember the human.
  2. Keep it rooted (on topic).
  3. No spam.
  4. Infographics welcome, get schooled.

This is a science community. We use the Dawkins definition of meme.



Research Committee

Other Mander Communities

Science and Research

Biology and Life Sciences

Physical Sciences

Humanities and Social Sciences

Practical and Applied Sciences

Memes

Miscellaneous

founded 2 years ago
MODERATORS