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

Multiple questions, fairly easy?

Asked by 10 years ago

What is a hexadecimal and how often do we actually use it in roblox?

print(tonumber("00001111",2)) -- why does this print 15
print( "\104\105" )-- why does this print hi

Nil vs false?

Thank you

1 answer

Log in to vote
1
Answered by
duckwit 1404 Moderation Voter
10 years ago

I'm not an expert when it comes to hexadecimal, but I don't think there is any ROBLOX-specific functionality that can't be operated with plain ol' Base 10.

tonumber("00001111") is Binary, or Base 2. Reading from right to left, the first digit represents the 1's column, the second digit the 2's column, the third digit the 4's column, the nth digit the 2^(n-1)th column. So you can read the example number you gave as "1 + 2 + 4 + 8 + 0 + 0 + 0 + 0", which equals 15.

"\" - backslash (as I call it, anyway) - is a special character when it comes to strings, it's usage is called Escaping, in the example you gave 104 and 105 are the ASCII byte codes for characters h and i respectively.

I think some other users are more able to comment on this than me, but as I understand it nil evaluates as false in any conditional expression, but false does not mimic nil in an assignment operation. For example if false then behaves identically to if nil then, but someVariable = false is not equivalent to someVariable = nil.

Ad

Answer this question