Absurdism corner

Why?


  • Total voters
    203

2298f212-46cb-4af5-b43b-363d1b2b6581.jpeg

evilchrispriestly-follow-theevilchris-lets-plant-catnip-he-said-29255959.png
 
The young lad/lass up there looks like a quick learner. I know that with that sort of early-years education, we can prevent children becoming IoT developers.

Talk to your kids about web security - before someone else does.
 
HTML:
javascript:var a=function(){alert(0.1*0.2); }()
put that into your URL (if you have FireFox)
 
HTML:
javascript:var a=function(){alert(0.1*0.2); }()
put that into your URL (if you have FireFox)
Is it the pseudo url, floating point math, alert dialog, or firefox that you find the most absurd? (Now I have to remember which machine I have firefox on to see if it does something unexpected)

Sent from my SM-N950U using Tapatalk
 
HTML:
javascript:var a=function(){alert(0.1*0.2); }()
put that into your URL (if you have FireFox)

Iceweasel 38.5 here. Nothing happens.

I'm curious to know what you'd expect to happen. Presumably something absurd?
 
HTML:
javascript:var a=function(){alert(0.1*0.2); }()
put that into your URL (if you have FireFox)
Pale Moon 28.5.0 here. Nothing happens.
[doublepost=1558171230,1558171131][/doublepost]Maybe absurd are we, trying it, expecting something to happen and getting confused. ?
 
I assume the expectation is an alert dialog displaying a slightly inaccurate value on browsers that support javascript pseudo urls

Sent from my SM-N950U using Tapatalk
 
@Binky @Djoga'Ro It would popup an alert dialog with "0.020000000000000004" and an OK button. The floating point of JS is not that good.

I have an old FireFox, maybe they removed it in the new FF. Try Waterfox instead, it worked there.
 
What is "not that good" about it? Do the same thing in C and you get 0.02000000141561031341552734375. That's just the nature of floating point numbers in a computer, you can't represent an infinite precision decimal, you can only represent "close enough", and if you'll notice, the JavaScript output is actually closer to what you'd expect than the C. Or is that the "not that good"? That it produces a different result than a true IEEE754 representation should?
 
You mean an infinite precision binary number, presumably. In decimal, the answer is 0.02 exactly, or 1/50 (because you're calculating 1/5 x 1/10). In binary that's slightly more than 0.00000001 (1/64), presumably an infinite precision binary, and when you try to store that in floating point, you effectively try to shift the decimal until the number becomes an integer; all of the digits are to the left, but with an infinite precision or simply too precise number that's simply not possible so it truncates it at its maximum resolution,

You could argue that this would be better if it used a decimal mantissa, so that it stored 2x10^-2 exactly, but in terms of the transistors and things inside a chip, when you have to divide by 10 it's relatively a killer. Dividing by 2 is simply a matter of shifting the bits one stop to the right and discarding the carry (also known as an ASR; an arithmetic shift right), which is easy to do in terms of transistors and traces. To divide by 10 (110 in binary) you're asking it to do long division every time, so it would be much slower. A slight loss of precision is usually considered preferable; in the javascript you're only out by something like 2.842170943040401e-14% (according to python's limited maths ability)
 
Back
Top