Difference between revisions of "Int"

From NWN Lexicon
Jump to: navigation, search
m
(+bitwise stuff)
Line 2: Line 2:
  
 
A signed 32-bit number. This is an actual number without a decimal and can be negative. Maximum 2,147,483,647, minimum -2,147,483,648, default 0.
 
A signed 32-bit number. This is an actual number without a decimal and can be negative. Maximum 2,147,483,647, minimum -2,147,483,648, default 0.
 +
 +
There is no boolean value in nwscript. TRUE is defined as 1 and FALSE is defined as 0.
 +
 +
A number of [[Bitwise Operators]] work in nwscript, allowing integers to store a lot of true/false information much more efficiently.
  
 
====Example====
 
====Example====
Line 8: Line 12:
 
int iAge = 23;
 
int iAge = 23;
 
int iResult = 2 + 2;
 
int iResult = 2 + 2;
 +
int bBoolean = TRUE;
 +
</nwscript>
 +
 +
Some example bitwsise operations:
 +
 +
<nwscript>
 +
int nValue = 0;
 +
int nTest  = 0x00000001;
 +
 +
if(nValue & nTest) // Will be false
 +
 +
// Add nTest to nValue
 +
nValue = nValue | nTest; // Can also do nValue |= nTest
 +
 +
if(nValue & nTest) // Will now be true
 +
 +
// Remove nTest from nValue
 +
 +
// Add nTest to nValue
 +
nValue = nValue & ~nTest;
 +
 +
if(nValue & nTest) // Will now be false again
 
</nwscript>
 
</nwscript>
  

Revision as of 13:37, 29 May 2020


A signed 32-bit number. This is an actual number without a decimal and can be negative. Maximum 2,147,483,647, minimum -2,147,483,648, default 0.

There is no boolean value in nwscript. TRUE is defined as 1 and FALSE is defined as 0.

A number of Bitwise Operators work in nwscript, allowing integers to store a lot of true/false information much more efficiently.

Example

int iAge = 23;
int iResult = 2 + 2;
int bBoolean = TRUE;

Some example bitwsise operations:

int nValue = 0;
int nTest  = 0x00000001;
 
if(nValue & nTest) // Will be false
 
// Add nTest to nValue
nValue = nValue | nTest; // Can also do nValue |= nTest
 
if(nValue & nTest) // Will now be true
 
// Remove nTest from nValue
 
// Add nTest to nValue
nValue = nValue & ~nTest;
 
if(nValue & nTest) // Will now be false again

See Also