cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Programming Trivia Pop Quiz: Be Different!

Highlighted

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
(789 Views)

Re: Programming Trivia Pop Quiz: Be Different!

This one is too easy

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

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

The discussions from the Advanced User Track is not over. Join in the conversation: 2016 Advanced Users Track
Message 2 of 10
(784 Views)

Re: Programming Trivia Pop Quiz: Be Different!

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
(729 Views)

Re: Programming Trivia Pop Quiz: Be Different!


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

Message 4 of 10
(718 Views)

Re: Programming Trivia Pop Quiz: Be Different!

ok found it...

Spoiler
thought about NaN .. but searched for a constant, didn't enter my mind before to just write it in Smiley Wink
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
(710 Views)

Re: Programming Trivia Pop Quiz: Be Different!

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
(518 Views)

Re: Programming Trivia Pop Quiz: Be Different!

@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
(494 Views)

Re: Programming Trivia Pop Quiz: Be Different!

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
(486 Views)

Re: Programming Trivia Pop Quiz: Be Different!


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. Smiley Happy

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 10
(435 Views)

Re: Programming Trivia Pop Quiz: Be Different!

    • input value:NAN

0 Kudos
Message 10 of 10
(313 Views)