JavaScript Floating point precision #computerscience #stem #javascript

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

It depends on if they’re floating point or doubles. If they’re floating point (which I assume they are) the anwser will be false.

BigBurgerBoy
Автор

abs(a - b) <= precision - more universal aproach especially when working with lower level languages like C, plus less function calls so less overhead

pepesob
Автор

For these numbers the issue is caused by base 2 floating point formats as used by the x86 and many other architectures . Some other systema use base 10 or base 100 and will hit 0.3 exactly . But every floating point format will have a precision limit that you need to deal with for most such examples, as the only guantee is that the error is less than some small number .

johndododoe
Автор

Hey Kira, just joined the AP CSA Java Review Course. Can you guide me on why kira-learning site says that this question answer is BABA?

String[] ab = {"A", "B"};
String[] ba = ab;
ba[0] = ab[1];
ba[1] = ab[0];
System.out.println(ab[0] + ab[1] + ba[0] + ba[1]);

According to w3schools, java visualizer, chatgpt and the community for stackoverflow, the answer is BBBB. They mentioned that ba[0] = ab[1], A no longer exists since ba[0] (A) = ab[1] (B). After this step, ba is now {"B", "B"} and since ab = ba, both ab and ba are {"B", "B"}. Which is why the answer is BBBB.

For kira-learning's answer, the only step I can think of on how they achieved this answer is treating ba[0] as variables and not changing the array. ba[0] = B, ab[1] = A, ba[0] = A, ab[0] = B. Thus answer is BABA.

So i have no clue which to trust, a course or the 3 websites and 1 online community for developers to learn

chuashanjing
Автор

a js problem a day keeps the programmer away 💀💀

qdaoffs
Автор

Where do you practice these questions?

yashh
Автор

That's bs why on earth the compiler makes it ! Unfair! The programming language need to be fixed 😅

utubevideos
Автор

Is there a simple reason why 0.1 + 0.2 equals or is it one of those things that will only make sense if you're hard into Java?

rizzpro
welcome to shbcf.ru