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 5
(231 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 5
(226 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 5
(171 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 5
(160 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.
0 Kudos
Message 5 of 5
(152 Views)