|
Hi All,
I've been tasked with converting a character representation of a binary number to it's decimal equivalent and vice versa. For example I have a series of nine characters '001011101' and I'm suppose to get the AS/400 to come up with 93. Or I have the decimal number 321 and I need to get to '101000001'
I've checked the archives and all past information deals with the conversion of a true binary number to decimal, not this character representation of one....
Is it possible to just move this string into a binary field and then to a regular numeric field?
------------------------------------------------------------------
H dftactgrp(*no) bnddir('QC2LE')
D strtol pr 10i 0 extproc('strtol')
D nptr * value options(*string)
D endptr * value
D base 10i 0 value
D ptr s *
/free
dsply (strtol('1': %addr(ptr): 2));
dsply (strtol('10': %addr(ptr): 2));
dsply (strtol('11': %addr(ptr): 2));
dsply (strtol('100': %addr(ptr): 2));
dsply (strtol('10010101': %addr(ptr): 2));
*inlr = *on;
/end-free
------------------------------------------------------------------As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.