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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Hexadecimal and binary numbers

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
tib Posted - 06/16/2003 : 11:29:48 AM
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.
1   L A T E S T    R E P L I E S    (Newest First)
greg Posted - 07/10/2003 : 5:22:33 PM
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



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000