Conversion to binary number (AREV Specific)
At 19 MAY 1999 11:47:44AM David Chan wrote:
I would like to calculate the length of a string in binary number. Is there a function for it, like LEN(STRING_NAME) but return a 2 byte binary?
Thanks!
At 19 MAY 1999 02:26PM Warren wrote:
Do a FMT('00':OCONV(LEN(string_var),'MB'),'R#2')
At 19 MAY 1999 07:21PM David Chan wrote:
Thank you Warren for your quick response! Unfortunately, what I want is to convert a number to its native binary number and not the ASCII of the binary number. Your solution will produce:
1=01
2=10
3=11
160=1010000 etc.. in ASCII bytes
whereas I would like to convert
160=รก
168=
211=+ which is the actual binary (now interpreted as ASCII for screen display).
I hope I am clear. Thank you!
At 19 MAY 1999 09:19PM Warren wrote:
You can just use the char() and seq() functions.
At 20 MAY 1999 09:51AM David Chan wrote:
I did try CHAR() function but it produces only with a single byte.
At 20 MAY 1999 10:04AM Eric Emu wrote:
SEQ() does what you require, so consult your manual, eg.
PRINT SEQ(168)
displays
Eric
At 20 MAY 1999 03:11PM Victor Engel wrote:
Digit1=INT(LEN(String)/256)
Digit2=MOD(LEN(String),256)
Binary=char(Digit1):char(Digit2)
or
Binary=char(Digit2):char(Digit1)
depending on what order you wish your binary to be in.
At 20 MAY 1999 03:59PM David Chan wrote:
Digit1=INT(LEN(String)/256)
Digit2=MOD(LEN(String),256)
Binary=char(Digit1):char(Digit2)
or
Binary=char(Digit2):char(Digit1)
Yes, I think this will do it - thank you all for your help!
David
At 20 MAY 1999 09:15PM Warren wrote:
Try this:
zero_mask=str('0',16)
no_bytes=len(x)
word=fmt1),'R#16')
hi_byte=char(iconv(word1,8,'MB'))
lo_byte=char(iconv(word9,8,'MB'))
word=hi_byte:lo_byte
the largest number that can be represented this way is 65535 (64K). Any number larger than 64K will get truncated (but in this example 'x' cannot be larger than 64K anyway).
It's easier to use hexadecimal:
zero_mask=str('0',4)
no_bytes=len(x)
word=fmt2),'R#4')
hi_byte=char(iconv(word1,2,'MX'))
lo_byte=char(iconv(word3,2,'MX'))
word=hi_byte:lo_byte
At 21 MAY 1999 10:40AM Warren wrote:
Then you can avoid all my previous nonsense by using v118 and V119:
hex_mask=char(0):char(0)
no_bytes=len(x)
call v119(no_bytes,hex_out) ; * converts decimal number to hex char
word=fmt(hex_mask:hex_out,'R#2')
To convert hex characters (binary) to decimal:
call v118(word,dec_out)
At 21 MAY 1999 09:50PM Warren wrote:
Whoops! What am I thinking? This function of V119 is from Revelation, not ARev. V119 in ARev is the sort function. Think they got rid of the old V119 and never replaced it; Aaron, Andrew, what say you?
At 22 MAY 1999 08:52AM akaplan@sprezzatura.com - [url=http://www.sprezzatura.com]Sprezzatura Group[/url] wrote:
V119 is alive and well in OpenInsight, sorting happily all you wish to throw at it. Same parameters as it's always been.
akaplan@sprezzatura.com
At 24 MAY 1999 03:02PM Warren wrote:
The V119 in Revelation had a totally different function than the V119 in ARev. Was this renamed something else in ARev or simply deleted? The Rev V119 did a decimal to hex conversion, output was in a 'binary' format.