The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Hexadecimal and binary numbers
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

tib

Switzerland
105 Posts

Posted - 06/16/2003 :  11:29:48 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Is there an easy way in LabTalk to convert decimal numbers into hexadecimal or binary strings?

I want to run a loop from 0 to 255 but use the hexadecimal string for example to generate a name.

The only thing I found in the manual was the function HEX() which returns the decimal number. Why is there nothing for the other way round? And for binary numbers? Do I have to write my own function? Or does anybody already have such a script?
Thanks, Tilman.

greg

USA
1380 Posts

Posted - 07/10/2003 :  5:22:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You would need to write your own code for this. You can write an OriginC function for hex strings pretty easily:

string gethex(int iValue)
{
string str;
str.Format("%X", iValue);
return str;
}

After building this you can use it in LabTalk:

%A = gethex(myintegervalue)$;
%A =;

For example:

myval = 16770219;
%A = gethex(myval);
%A =;

would yield:

FFE4AB


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000