× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Use the C function itoa.
First convert from hex to char (e.g., X'F1' ->  '1')
Then use itoa with a radix parameter of 2 for binary.
I'll convert it for you.

-Bob


-Bob Cozzi
www.RPGxTools.com
RPG xTools - Enjoy programming again.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On
Behalf Of Leif Guldbrand
Sent: Saturday, April 08, 2006 3:40 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Convert from Hex to Binary....

Hi,

I receive some data from a industrial I/O box (Beckhoff BK9000) thru
Modbus protocol over TCP/IP in my socket client program (thanks Scott :)

One byte is the status of 8 input registres and is received in Hex from
x'00' to  x'FF'.

I need to change this value into a binary string.

An example.... I receive the value x'80' which should be converted to
'1000 0000' and end up in a data structure with 8 fields.

I've Googled around, but could only find the thing I want, doing it with
REXX and the function   X2B('C3')        ->  '11000011'

I want to do this inside my program.... any help out there ???

Best regards,
Leif



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.