bed
Converts a number to binary coded decimal (BCD).
Defined in header <bcd.h>
Syntax
#include <bcd.h>
bed bcd(int x);
bed bcd(double x);
bed bcd(double x, int decimals);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ |
Remarks
All of the usual arithmetic operators have been overloaded to work with bed numbers.
bed numbers have about 17 deeimal digits precision, and a range of about 1 X 10-^25 to 2 X 10125.
Use the function real to convert a bed number back to a float, double, or long double.
The argument decimals is optional. You can use it to specify how many decimal digits after the decimal point are to be carried in the conversion.
The number is rounded according to the rules of banker's rounding, which means round to nearest whole number, with ties being rounded to an even digit.
Return value
The bed equivalent of the given number.
See also
Example
#include <iostream.h>
#include <bcd.h>
int main(void)
{
bed a = bcd(x/3,2); // a third, rounded to nearest penny
double X = 10000.0; // ten thousand dollars
cout << "share of fortune $" « a « "\n";
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/bcd.h/bed/
· short form /3.1/bed/