I have been completing this challenge, i completed it but I’m a bit curious about this floating points that is said as a note. I tried searching on the web but i can’t understand it. Can you teach me in a way i can understand?
Also I am doubtful about the previous challenge with ++ operator. I searched for it on the web and that made me very confused.
This is the link to what i found on web. I have a few Questions on it:
On the first try it example, after running it why did it say x:4, y:3. The x was declared as 3 and only y was declared as x++. The results should have been x:3, y:4. Am I right?
These are the Questions i have right now.
Thank you for reading this topic
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
As that challenge says, floating point numbers are numbers with decimals in them. Because there are an infinite amount of these numbers, computers have to approximate their values when they store them in memory. Thus, calculations using floating point numbers won’t always come out the way you think they will because they can’t be as precise as you might like them to be due to these approximations. For example, open the console in your browser tools and type the following equation:
4.001 - 3.001
You and I both know that the answer is 1. What does JS think it is?
Granted, the answer JS gives is pretty dang close to 1, but not perfect. Depending on the values you are working with these irregularities could affect your calculations. That’s what the note was trying to explain to you.
I extremely sorry about the link to the project, i had already included the link but it was pushed down by the text i added above.
I understand floating points now. You explained it in a simple way. I calculated your equation on the console and i was expecting it to give me 1 as the answer, but as you said it gave me the answer 1.0000000000000004 .