# Floating Point Accuracy

Describe your issue in detail here.

The video says that multiplying floats is the same as multiplying numbers. While the previous video had a link about how floats are prone to errors.

I think it is more accurate to say that they are similar enough for our purposes that we will treat them as the same.

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0`

Challenge: Multiply Two Decimals with JavaScript

Its basically giving you a heads up to keep an eye out for floating numbers. Yes you can add them together similar to integer numbers, but you might not always get the answer you are expecting.

adding 0.1 and 0.2 we would expect the result to be 0.3, but because floating numbers we end up with 0.30000000000000004. You donât have to worry about it to much right now, but later on you will need to deal with this.

It depends how much accuracy you want. But since computers are base 2, no fraction that is not an exponent of 2 can be represented with perfect precision with finite digits. Similarly in base 10, only fractions that are a combination of exponents of 2 and 5 can be accurately represented: 1/2 = 0.5, 1/5 = 0.2, 1/10 = 0.1, 1/4 = 0.25, etc. Anything else is impossible to represent with a finite number of digits, e.g., 1/3, 1/5, 1/11, 1/6, etc.

I realize I donât need to worry about the difference now, but if someone is of the belief they are the same and are working on probes and satellites going to other planets in our solar system, it is good to set an example that: for our teaching model it doesnât matter, but for high level science it really does.

I once had medication that said it was the exact same medication I was taking. I assumed with the language that was used it was identicalâŚ it was not. It was the same type of medication but the dosage was very different.
Many people are able to see the meaning behind what is said, instead of what is actually said. Some people are very literal in their communication and have difficulty when others are not as literal. I just wanted to point out that the way it is presented in this video could trip some people up.

Iâm confused. Floating point arithmetic is not exact. I think we all agree about that.

We use the same symbol for multiplying whole numbers and decimal numbers. The syntax is the same. Thatâs what this means

In JavaScript, you can also perform calculations with decimal numbers, just like whole numbers.

But anyone that is doing that level of math is going to know the limitations of floating point arithmetic and how to work around it in various languages and libraries. It would be prohibitive in an entry level course to go into that level of detail on a subject that is just going to bore people, isnât going to matter 99.99% of the time for most of us, and most people would quickly forget at this point anyway. I think it is enough to say that floating point arithmetic has some limitations. If people are curious, they can look it up.

1 Like

I am referring to the video, where it says that working with floats is the same as working with numbers. My point is that they are similar, not the same.

The syntax is the same. The one of the big points behind using high level languages is that you donât have separate `i32Multiply(a, b)` and `f64Multiply(a, b)`.

I agree going in depth is not worth it in a beginning class, But I donât agree in saying they are the same. It would be like saying PI is the same as 3.14. It is similar enough for basic learning to call it good, not worth going into the exactness of it.

I agree the syntax is the same, but if I believe the results will always be the same I might fall into trouble later. There are quite a few things that have the same syntax or procedures, but quite different results.

Maybe I missed it, but I donât think the video makes such a guarantee that floating point multiplication is perfectly exact.

It just really stood out to me as the video before it made sure to provide a link as to why it wasnât exact. And if someone doesnât watch all the videos, they may miss that portion.

The video says that the syntax is the same. The written challenge information says that the syntax is the same. Thatâs what âthe same asâ means in this context. Nobody said or meant that floating point multiplication is perfectly accurate in the video or the written challenge description, that I could find.

I think yu are reading too much into saying that they are âthe sameâ. Itâs about context an expected level of exactness. I was talking to a friend here in Spain and mentioned the American grocery store Safeway. He didnât know what it was so I said it was the same thing as Carre Four. Now, of course, they arenât exactly the same thing, but for the purposes of that convrsation, it was good enough.

Smilarly, for explaining how JS mathematical operators work, saying integer and flouting point math are he same is good enough.

Every programming learner will eventually run into floating point errors and will learn from the experience. And I think that that will stick in their head better.

No professional programmer is going to not understand this. The only way that could happen is if they get hired after only learning the very basics of coding, And in that case, the employer deserves what they get. NASA is not hiring coders with two months of self-taught coding.

2 Likes

Well, when the previous video makes mention of the errors, and they say % is not Modulus but remainder, it leads me to believe that they are going for accuracy.

As far as reading too much into it, I donât think I am the only person who would have questions about that, but I was willing to risk looking like a fool for pointing it out.

And given that there is very non-specific or implicit language in English that we use specific or explicit words to mean things in coding, like = is assign, == is equal to or compare, saying equivalent is a much more accurate term without going into a long explanation that would bore most newcomers.

In JavaScript, you can also perform calculations with decimal numbers, just like whole numbers.

I donât see anything wrong with this statement.

We arenât updating any of the videos anymore. If you feel strongly about this, you can create a GitHub issue requesting that this video be deleted.

âMultiplying decimal point numbers or floating point numbers is the same as multiplying intergersâ Those the the first words of the video.

But I get that not everyone is going to see it the same way as I do, and that is ok. Iâm just looking out for those who tend towards a more literal interpretation of words instead of massaging it to what the person ment to say.

If you feel strongly about this, you can request that the video is deleted from the curriculum. This would be via a GitHub Issue.

Otherwise, this conversation is flogging a dead horse at this point. We all understand what the video means. We understand that you believe some learners might draw some wrong interpretations from the video. We disagree. The only fix available is deleting the video.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.