Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Input hexadecimal in LSL

Hiro Yamamoto
Registered User
Join date: 1 May 2003
Posts: 44
04-26-2004 13:27
It would be nice for certian things to be able to use hex in lsl for instance:

integer i = 0xFF42; // equiv to i = 65346
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
04-26-2004 16:54
Im a bit inexperianced in the traditional programming sence (I know what hex is, just have never used it in practice), mind enlightening me of a use of something like this?
Carnildo Greenacre
Flight Engineer
Join date: 15 Nov 2003
Posts: 1,044
04-26-2004 22:46
Most commonly, hexadecimal input is used when you're setting up a set of one-bit flags to be stored in a single variable. For example (in C):

CODE
const int CAN_FLY = 0x01;
const int CAN_WALK = 0x02;
const int CAN_ROLL = 0x04;
const int CAN_HOP = 0x08;
const int CAN_DRIVE = 0x10;
const int CAN_FALL = 0x20;
const int CAN_TELEPORT = 0x40;
const int CAN_WOBBLE = 0x80;


It's much easier to keep track of what bits you've used and what ones are available if you're working in hex.
_____________________
perl -le '$_ = 1; (1 x $_) !~ /^(11+)\1+$/ && print while $_++;'
Bino Arbuckle
Registered User
Join date: 31 Dec 2002
Posts: 369
04-27-2004 09:56
CODE

integer CAN_FLY = 1;
integer CAN_WALK = 2;
integer CAN_ROLL = 4;
integer CAN_HOP = 8;
integer CAN_DRIVE = 16;
integer CAN_FALL = 32;
integer CAN_TELEPORT = 64;
integer CAN_WOBBLE = 128;


Works equally as well in LSL. I suppose working in hex is easier since there's a logical sequence of values... but, multiply by 2 is an easy enough sequence to remember also. And no less complex than someone learning hex to program LSL.

Edit: ouch the PHP color scheme is painful. Didn't realize that CODE was still supported (or was the sharp/pound)