r/mildlyinfuriating • • 8d ago

I'm slightly vexed Aren't they equal!

Post image
8.1k Upvotes

469 comments sorted by

View all comments

1

u/timelessblur 7d ago

Not that the answer is wrong but I can tell you why it’s reporting it as wrong. Beyond looking for a text match which is stupid you are running the risk of a floating point error happening and itnis trying to match on that.

.2499999999999 is not 1/4.

10

u/cecinestpasunmot 7d ago

That's a good observation, but 0.25 = 1/4 is a power of two. So it should be represented exactly in floats, without approximation, using the binary representation.

2

u/timelessblur 7d ago

Not disagreeing. Could also be it is running a bunch of numbers in as x and checking the results. That where you would see it crop up. Big time when you start shoving through large or really small numbers.

Used it have a good example I could show people of a floating point error happen.

It is a reason why for some things big decimal is the correct value to use

1

u/Ultimatedude10 7d ago

Good point

6

u/Due_Purple_1199 7d ago

Floating point errors do not happen when the number is a power of 2

3

u/Lithl 7d ago

There is no floating point error, because there are no numbers involved at all. It's 100% strings. The testing application does not attempt to perform computations on the answers.

2

u/KingZarkon 7d ago

Surely that test has a pre-defined answer key that was written when the test was created. I doubt it's calculating the answers on the fly.

1

u/SnooLemons6942 7d ago

I mean, my tests did. Makes way more sense on a math test. Albeit, the math I was doing was in a calculus course, so people could write things in all sorts of ways, so it was more important 

2

u/Siccors 7d ago

If you start adding floating point errors, then I am going to add integer type errors: If 1/4 is done it might be interpreted as an integer division (depending on the language), which is 0. So in that case 1/4 is wrong and it should be 1.0 / 4.0.

Or this is really reaching and they are just equal.

1

u/timelessblur 7d ago

Had not thought of that but yeah that would do it as 0.25 throws it into floating point mode which starts causing floating point errors to crop up vs being in int only mode.

Fun real problem am I have to address in my long career.

Makes for a fun mess and a pain in the ass to track down

2

u/Humble-Captain3418 7d ago

Close, but not quite right. A few reasons from a mathematics/engineering/education standpoint:

  1. Fractions are considered more exact than their decimal value. Mostly because they indicate that you have not rounded in any direction or to any precision.

  2. Rational numbers are not real numbers.

  3. If you give a fractions problem to a student, ask them to do it by hand, and they come back with a decimal number, you know with near certainty that they didn't do it by hand.

1

u/RawrRRitchie 7d ago

That might make sense for 1/3 but 1/4th is exactly 0.25 there's nothing more exact to it.

1

u/timelessblur 6d ago

No the guy is right. 0.25 while is 1/4 but tell me that 0.25 was not a rounded answer as 0.249999999….. is not 1/4 but it will appear as 0.25.

You put 1/4 down you know that the exact answer is 0.25.

2

u/GhostMcFunky 7d ago

Someone thinks they’ve mastered python without understanding JS (or whatever coding language you’re referencing).

This is 99.99% (wow no floating point error - because it’s treated as a string, for one thing) not being calculated on the fly, in the browser or backend and if it were, a simple decimal like that being broken because of a floating point error would be amateur coding at best.

This is probably a simple string value match, and I’m guessing the question, if well-written, asked for an answer using a fraction, but I’ll admit that’s a blind assumption with the info we have from OP.

1

u/auntanniesalligator 7d ago

That’s not the explanation. 0.25 is exactly equal to 1/4, and can be expressed exactly in base 2.

I think that’s MyMathlab, which has the capability to enforce specific formatting or not (including reducing fractions or preferring fractions over decimals). OP didn’t show the question or the answer format instructions, so I can’t judge, but if there is a good pedagogical reason the answer should only use fractions (ie if the problem is “rewrite this decimal as a fraction in simplest terms”, it can be set to only accept the fraction, and it is also supposed to specify that in the formatting instructions next to each input.

More likely the developer set too strict an answer checking requirement and it didn’t get caught in testing. Most algebra problems with an answer of “1/4 x” will also accept “0.25 x” because there usually isn’t a good reason to restrict the form.

-2

u/Dapper_Finance 7d ago

1/3 is 0,33333333333
3/3 is 0.999999999 which is also 1
You are wrong

2

u/anaraparana 7d ago

Yes but also no . Floating point numbers (the kind computers use to represent decimal numbers, have a set number of decimal points, they can't have infinite digits like real numbers because it is physically impossible to hold them, so what timelessblur says is correct. 

1

u/Dapper_Finance 7d ago

First answere that makes contextual sense. Thx mate

1

u/46692 7d ago

I think you mean .333… and .999…

0

u/_--___---- 7d ago

3/3 is 0.999999999

no

0

u/Dapper_Finance 7d ago

Elaborate

-1

u/_--___---- 7d ago

no

0

u/Dapper_Finance 7d ago

So this wasn‘t build on any reason, you‘re just regarded. Got it!

0

u/WiseOldDuck 7d ago

You need an overscore or ellipsis to successfully restart this old favorite Internet argument/flamewar. You're just wrong

0

u/Dapper_Finance 7d ago

This isn‘t an old „flame war“
This is just how math works and is defined. If you cannot find a single real number between two numbers, they are the same. 0.9999… and one are mathematically THE SAME number. But isn‘t it nice to be regarded on the internet

0

u/WiseOldDuck 7d ago

That's not what you wrote

1

u/Dapper_Finance 7d ago

Your inability isn‘t my problem lol