Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
8

what does NAN mean? [closed]

Asked by
tumadrina 179
10 years ago

I was trying to figure out how to do some things with the mouse, and what better way then trying stuff out so I did this on a local script

Mouse=game.Players.LocalPlayer:GetMouse()
print(Mouse.hit)

the output printed as

0, 0, 0, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN

Locked by theCJarmy7, GreekGodOfMLG, User#21908, and User#5423

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
25
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

NAN is short for "Not A Number". C (ROBLOX stuff) calls it this -- Lua calls it something like "#INDEF" (indefinite).

Operations like 0/0 will cause this to appear.

Any operation on NaN will produce another NaN.

NaNs are usually big problems because of this, since they will "contaminate" any other values you try to use them with. Since only a few operations can create them (inverse trig functions and division by zero and operations on infinity), you only need to be careful of a few cases (usually just division).


In this case particular case of the Hit property, it isn't your math; ROBLOX has decided these values behind-the-scenes.

It probably means that the camera is not defined correctly or the mouse hasn't "loaded" yet (the player hasn't pointed at anything or is not pointed at anything).


Regardless, those NaNs are okay, though, because the orientation of the Hit property isn't ever important, only the position .p is, which is the first three numbers - and those are not NaN.

Ad