BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Programming Trivia Pop Quiz: Be Different!

Unlike the last question, this one should be common knowledge for everybody.

 

QUESTION: Find a value that will cause the boolean to be TRUE when the code is executed.

 

BeDifferent.png

Message 1 of 10
(12,086 Views)

This one is too easy

Spoiler
There is not a number that will return TRUE here.Smiley Wink

GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 10
(12,081 Views)

answer:

Spoiler
might this be a trick question?
i know that you cannot guarantee x + (y+z) == (x+y)+z for floating points,
but to compare the same number/bit-representation against each other should never be different.

If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 3 of 10
(12,026 Views)

@jwscs wrote:

answer:

Spoiler
 
Spoiler
Spoiler
might this be a trick question?
i know that you cannot guarantee x + (y+z) == (x+y)+z for floating points,
but to compare the same number/bit-representation against each other should never be different.

If you look at the definition of floating point numbers, there is a case where it SHOULD be different.

 

 

 

That condition is what Christian is trying to teach us about with this trivia question.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 10
(12,015 Views)

ok found it...

Spoiler
thought about NaN .. but searched for a constant, didn't enter my mind before to just write it in 😉
strange-math2.png

guess from mathematical standpoint it makes sense, since the value is undefined
links: https://en.wikipedia.org/wiki/IEEE_754#Formats
https://stackoverflow.com/questions/1565164/what-is-the-rationale-for-all-comparisons-returning-fals...

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 5 of 10
(12,007 Views)

My first guess was either +inf or -inf.  Interestingly enough, this returns false.  I guess you could prove that a double precision float is countably infinite...

0 Kudos
Message 6 of 10
(11,815 Views)

@BownM i must disagree with you, since you only have a finite number of bytes for the representation, it follows, that there can only be a finite number of different numbers.


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 10
(11,791 Views)

According to IEEE-754, there is exactly one unique bit pattern for +inf and -inf, respectively. However, there is a huge number of different NaNs. (details)

Message 8 of 10
(11,783 Views)

@jwscs wrote:

@BownM i must disagree with you, since you only have a finite number of bytes for the representation, it follows, that there can only be a finite number of different numbers.


Approximately 18.4*10^18 unique combinations. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 10
(11,732 Views)
    • input value:NAN

0 Kudos
Message 10 of 10
(11,610 Views)