There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

supercriticalcheese , in The difference

source: SMBC link

Inductor OP ,

Thanks, I didn’t know where it came from.

HKPiax , in 0.30000000000000004
@HKPiax@lemmy.world avatar

I’ve always tried understanding this floating point thing, but I never could. Could anyone here please ELI5?

jana ,

Computers are binary, yeah? So we have to represent fractional numbers with binary, too.

In decimal, numbers past the decimal point are 10^-1, 10^-2, … etc. In binary, they’re 2^-1, 2^-2, …

2^-1 is one half, so 0.1 in binary is 0.5 in decimal. 2^-2 is one quarter. 0.11 in binary is 0.75 in decimal. And of course you’ve got 0.01 = 0.25

The problem comes when representing decimal numbers that don’t have neat binary representations. For instance, 0.1 in decimal is actually a repeating binary number: 0.0001100110011…

Rentlar , (edited )

My ELI5 is this. Pretend you have a robotic pizza cutter, but the only thing it can do with a pizza or pizza slice is cut it in half. If you ask for a tenth of a pizza, well it can give you an 1/8 or a 1/16 by repeatedly cutting a slice.

It can also cut you a 1/16 slice, make 1/32, 1/256, 1/512 and 1/2048 slices separately, shift them together for you and be like: “There. Here’s 0.100098 of a pizza. You happy?”

(You can also think of it as the robot cutting the pizza into 2048 slices and mushing together 205 of them to make your “tenth”).

HKPiax ,
@HKPiax@lemmy.world avatar

This is absolutely brilliant. Perfect ELI5, thanks! Would you be so kind to make it so it’s about the binary thing with computers?

Rentlar ,

Sure I can try to connect the metaphors, in a binary number system you have numbers 1 or 0 to pick from. How it applies in this scenario is that you can only have up to one slice of each size. That works because if you want two of it, you would instead replace it with a one size bigger slice that is equivalent to 2x the smaller size.

For a general understanding of floating point I suggest you learn binary first and separately, because at the end of the day it’s just another way to write base-10 numbers. Floating point representation is useful because the basic principle is you pick some fraction that is so small relative to what you’re measuring, so you can do most math accurately. (e.g. If I say this dwarf planet is the size of our moon and a 20 tennis balls, the tennis balls don’t really change your idea of how big it is)

At the end of the day, FP is like scientific notation but with like 10 significant digits.

soggy_kitty ,

ChatGPT alarm bells

Rentlar ,

I ain’t ChatGPT. My comment there kind of sounds like it tho.

ruk_n_rul ,

People tend to forget ChatGPT learns from people’s comments, like yours.

merc ,
Psythik ,

My head hurts just trying to comprehend that article.

God I suck at math.

merc , in 0.30000000000000004

It’s not + that’s scary, it’s =.

maniacal_gaff ,

==

merc ,

Sometimes…

livingcoder , in me_irl

hook to Insomnia plays

Quindius , in Welp, guess I'm going to hell

At least God isn’t a crypto bro

dylanTheDeveloper , in 0.30000000000000004
@dylanTheDeveloper@lemmy.world avatar

Quaternions scare me more

Metal_Zealot , in Welp, guess I'm going to hell
@Metal_Zealot@lemmy.ml avatar

“It seems you have an ad blocker enabled. In order the enjoy the full benefits of heaven, please disable it and accept our cookies”

xusontha OP ,

bro who is selling ads in heaven

Metal_Zealot ,
@Metal_Zealot@lemmy.ml avatar

Google Adsense has a further reach that you think

Aelar64 , in 0.30000000000000004
@Aelar64@kbin.social avatar
MBM , in Programming Languages as Essays

Brainfuck: it’s technically an essay, but who in their right mind would write it using only the first eight letters of the alphabet?

Nioxic ,

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++++.–…++++++.

xigoi , in 0.30000000000000004
@xigoi@lemmy.sdf.org avatar

If you’re working with floating point, you should be aware it’s just an approximation.

kevincox ,
@kevincox@lemmy.ml avatar

People think floats are too magical. Calling it an approximation is sort of leaning into this. Floats have limited precision like every other fixed size representation of a number.

This is sort of saying that integers are an approximation because int(1.6) + int(2.6) = 5. What do you mean‽ Clearly 1.6 + 2.6 = 4.2 ~= 4!

Floating points can’t perfectly represent 0.1 or 0.2 much like integers can’t represent 1.6. So it is rounded to the nearest representable value. The addition is then performed perfectly accurately using these values and the result is the rounded to the nearest representable value. (Much like integers division is “rounded”). That result happens to not be equal to the nearest representable value to 0.3.

It is definitely a bit surprising. And yes, because of rounding it is technically approximate. But the way people talk about floating point makes it sound like it is some nebulous thing that gives a different result every time or just sort of does the correct thing.

r00ty Admin ,
r00ty avatar

I think specifically, they have amazing precision. But the boundaries just don't fall perfectly on round numbers we humans would expect. That's what gets people confused.

Rounding can resolve these problems, or don't use float if you don't need to.

merc ,

The difference is that when you input a specific, precise floating point number, the number that’s stored isn’t what you entered.

When you enter integers and store them in ints, as long as the number is small enough, what’s stored is exactly what you entered.

If you tell your program that the radius of the circle is 0.2 units exactly, it says OK and stores 0.200000000000000011102230246251565404236316680908203125.

Of course everybody knows that there’s a limit to how many digits get stored. If you tried to store Pi, there’s obviously some point where it would have to be cut off. But, in life we’re used to cutting things off at a certain power of 10. When we say Pi is 3.14 the numbers after the 4 are all zero. If we choose 3.14159 instead, it’s the numbers after the 9 that are zero. If we represent these as fractions one is 314/100 the other is 314159/100000. The denominator is always a power of 10.

Since computers are base 2, their denominator is always a power of 2, so there’s a mismatch between the rounded-off numbers we use and the rounded-off numbers the computer uses.

Anticorp , in Pure Evil

I knew a guy who used the Unicode character for a space in his password. He figured if anyone ever saw his password they’d think it was a space and still not be able to use it. It’s silly, but it was a fun thing to learn about him.

bc001 ,

Which character. Does it need Combination of keys or a Single key.

Anticorp ,

A combination of keys. I don’t remember the code anymore.

quinkin ,

Alt-255 was the old-school method.

Cow_says_moo ,

I use alt 0160 for a non-line breaking space.

CanadianCarl ,

I can’t type alt codes with my keyboard.

shasta ,

That’s pretty neat, but also means he will never be able to log into things on mobile

elint ,

Bitwarden has no problem filling passwords containing unicode characters on Andorid.

JoCrichton , in Welp, guess I'm going to hell

Guess I’m continuing to use Firefox in hell then

xusontha OP ,

Join the club!

TheGiantKorean , in Programming Languages as Essays
@TheGiantKorean@lemmy.world avatar

Perl: this essay is just one long run on sentence.

akincisor ,

He just kept talking in one long incredibly unbroken sentence moving from topic to topic so that no one had a chance to interrupt, it was really quite hypnotic.

nyan ,

With some very odd random punctuation. (I love Perl, but some of the built-in variables . . .)

TheGiantKorean ,
@TheGiantKorean@lemmy.world avatar

Lol yes. Like… How is $_ intuitive?

StarkillerX42 , in Markdown everywhere

One of these days, someone is going to invent a confluence alternative that only supports markdown and doesn’t have nay of confluences stupidity and it is going to EXPLODE and bankrupt Atlassian.

StarkillerX42 , in Always commit

No babe! I was busy doing review!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines