0
How do you write a program, which compares correctly two real numbers with accuracy at least 0.000001?
11 Respuestas
+ 23
@Mandla this takes absolut values of a and b and does the following (if (a-b) <0.000001 (ideally that must be: a-b = 0) then a == b)
but if a < b it'll say false anyway
https://code.sololearn.com/cddiqf9EtJPJ/?ref=app
+ 22
😆
+ 22
here it`s 3.30am.. well, then we`ll need smthn to not miss those questions
+ 21
@Mandla Convert.ToDouble(Console.ReadLine(());
idk but u can write smth like this "Evaluated with accuracy of 0.000001 ))"
+ 19
@Mandla post here example of your current code plz
+ 5
How about multiplying them by 1000000?
+ 2
@Illusive man
You have officially become my go to bro cause my brains are burning, I'm complete newbie at this.
Thanks a million Illusive man
+ 1
illusive man
I'm studying c# fundamentals this was question 3 of the exercise. I was asked to compare correctly two real numbers with accuracy of at least 0.00001.
+ 1
@Illusive man
Where do you get the values you gave to the variables you initiate and how does one find or know the accuracy of 0.000001?
By the way thanks for your help
Exercise 5 is the worst
I'm asked to declare a variable of type char, assign it as a value the character, which has a Unicode code 72 and display it as a hexadecimal representation.
+ 1
Bro I'm in South Africa and it's past 2 am I 'm waking up in 5 hrs to go to campus I will be posting more Questions and I wish to hear from you again. 😴😴
0
The guideline gave me an e.g.
bool equal = Math.Abs(a-b) < 0.000001;
But I still don't understand how this work🙁