View Full Version : Is there a way to add hex values?
mrdude
09-18-2005, 04:27 PM
Hi sorry to bother you guys again - I am making a small app and I want to be able to add two hex values together - I can do this with decimal numbers easily, however the result when adding two hex numbers is wrong. Can APMS 6 do this? and how? thanks.
mrdude
09-18-2005, 05:18 PM
Hmm I couldn't find the edit button to edit my post:
Here is what I'm trying to do:
-- gets the hex number from inputmac
get = Input.GetText("Inputmac");
-- converts the hex number to decimal
hex = Math.HexToNumber(get);
-- converts the hex number 1 to a decimal number
hex2 = Math.HexToNumber(1);
-- Adds the value from Inputmac + 1
sum = hex + hex2
-- Displays the added result in decimal
Dialog.Message("Result", sum, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
If you look at the following code it outputs a decimal number- How can I change it so that it outputs a Hex number - Basically I wish to add the hex value of 1 to a MAC address from a database.
Brett
09-19-2005, 09:47 AM
Do this instaead for the last line:
-- Displays the added result in decimal
Dialog.Message("Result", string.format("%x",sum), MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
mrdude
09-19-2005, 10:10 AM
Wicked m8, that worked a treat. Thanks very much. :)
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.