generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Why is nan~=nan

Previous Thread :: Next Thread 
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 12:24 PM
local nan1=0/0
local nan2=50/0
print(nan1,nan2)
print(nan1==nan2)
print(nan1==nan1)
print(nan1==0/0)
print(nan1~=nan2)
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 12:27 PM
also why is 50/0 registering as inf instead of nan even though it is still division by 0
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 12:33 PM
bump
didnt see anything too interesting in the c setups
Report Abuse
AxonMega is online. AxonMega
Joined: 29 Aug 2014
Total Posts: 2403
08 Feb 2017 01:08 PM
They made it like that so you can check if a number is not real.
Report Abuse
inception101 is not online. inception101
Joined: 19 Dec 2010
Total Posts: 738
08 Feb 2017 01:11 PM
It might answer your question if you set nan1 = 1/0 in the above script


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
08 Feb 2017 01:29 PM
because -1.#IND ~= 1.#INF

and -1.#IND ~= 0/0




Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 03:10 PM
no but nan1==nan1 returns FALSE...
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 03:36 PM
like i cannot see the logic why nan is not nan

print(0/0==0/0)

it is very very strange...

also here is something extremely ironic

print(type(0/0))

nan stands for Not a Number yet type says it is a number xDDDD
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
08 Feb 2017 03:39 PM
it doesnt matter

stackoverflow
.
com
/questions/19107302/in-lua-what-is-inf-and-ind


Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 03:40 PM
i dont care about 10/0 not being 0/0 i want to know why 0/0 is not 0/0

Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 04:01 PM
bumpy
Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
08 Feb 2017 04:04 PM
dividing by 0 is undefined

something undefined cannot be equal to anything as it does not exist in the first place.
Report Abuse
EchoReaper is online. EchoReaper
Joined: 14 Oct 2008
Total Posts: 4323
08 Feb 2017 04:16 PM
"also why is 50/0 registering as inf instead of nan even though it is still division by 0" If you take Calculus you'll learn that dividing by 0 is practically infinite in most cases. The only reason we don't define the result of dividing a non-zero number by zero as infinite is because it's not true 100% of the time. "something undefined cannot be equal to anything as it does not exist in the first place." would be the semantic answer. For Lua to be able to tell that 0/0 == 0/0, it'd have to know what 0/0 was before it became -inf, and it doesn't store this information. This is the same for non-zero divisions by zero as well, meaning 5/0 ## #### ## math.huge. The reason 0/0 ~= -1/0 even though they don't print out the same value is probably because of an edge case in Lua (if dividend == 0 and divisor == 0 then) where 0/0 returns a different type of undefined value that always returns false in comparisons.
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 10:33 PM
but doesnt nil represent a non existent value but nil==nil is true
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 10:35 PM
and i still find it funny that type(nan) is a number
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
08 Feb 2017 10:38 PM
No the reason nans are not equal to each other is because they're designed to be that way.

Technically there are 2^53 - 1 different NaNs (the representation) but that's not the reason. The reasons from what I assume are that dealing with NaNs can cause problems if you don't get value out of it.

i.e. x < nan will always yield false because nan cannot be greater than or less than any other number (or nan). The reason nan ~= nan was probably so it was easy to determine if a number was nan.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
08 Feb 2017 10:39 PM
"if you don't get value out of it."
meant to say if you don't get nan out of it (it being comparing it or doing arithmetic blah blah)
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 10:41 PM
but to know if a number is nan you would have to compare it to being under or above numbers or to it having a denominator of 0

and lua thinks Not a Number is a number which i assume is just for simplicity
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
08 Feb 2017 10:42 PM
"and lua thinks Not a Number is a number which i assume is just for simplicity"
It's not Lua that thinks that. It's because NaN's type _is_ a number. It's represented just how every other number is represented, except that the exponent = 2^expbits-1 and mantissa ~= 0
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 10:45 PM
is there a way to know if the result of division is undefined for numbers other than 0 because it returns infinity so i think you could only find out if you know the denominator because you could have inf/1
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 10:46 PM
i think i should just make my own undefined value that can be returned from using a division function
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
08 Feb 2017 10:55 PM
1 #include [stdio.h]
2
3 int main() {
4 float a = 1.0 / 0.0;
5 float b = 2.0 / 0.0;
6
7 printf("%f : %08x / %f : %08x\n", a, b);
8 return 0;
9 }


inf : 610cbb48 / inf : 610cbb58
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
08 Feb 2017 10:56 PM
Oops a,a, b,b
Report Abuse
scottmike0 is not online. scottmike0
Joined: 14 Sep 2008
Total Posts: 1073
08 Feb 2017 10:57 PM
at least using the console in chrome

that is simply not true.

I tested with the values 30/0 and 50/0

essentially I compared 30/0 == 50/0
and received true.
but what I also got is that 30/0 == infinity
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 Feb 2017 10:58 PM
no you are incorrect, nan is a result of 0/0 apparently, not any larger or smaller numbers
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image