Syntax, Example, Bcd2bin( ) built-in function – Echelon Neuron C User Manual
Page 94: Bin2bcd( ) built-in function
74
Functions
Syntax
#include
void application_restart (void);
Example
#define MAX_ERRS 50 int error_count;
...
when (error_count > MAX_ERRS)
{
application_restart();
}
bcd2bin( )
Built-in Function
The bcd2bin( ) built-in function converts a binary-coded decimal structure to a
binary number. The structure definition is built into the compiler. The most
significant digit is
d1
. Note that
d1
should always be 0.
Syntax
unsigned long bcd2bin (struct bcd *
a
);
struct bcd {
unsigned
d1:4,
d2:4,
d3:4,
d4:4,
d5:4,
d6:4;
};
Example
void f(void)
{
struct bcd digits;
unsigned long value;
memset(&digits, 0, 3);
digits.d3=1;
digits.d4=2;
digits.d5=3;
digits.d6=4;
value = bcd2bin(&digits);
//value now contains 1234
}
bin2bcd( )
Built-in Function
The bin2bcd( ) built-in function converts a binary number to a binary-coded
decimal structure.