⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bcdd.doc

📁 c语言库函数!里面包含了所以c语言中的系统函数的实现及其详细说明和代码!请大家及时下载!
💻 DOC
字号:
+++Date last modified: 05-Jul-1997

---------------------------------------------------------------
bcd_to_double()
---------------------------------------------------------------
NAME:
    bcd_to_double() - Converts a binary coded decimal value to type double.

SYNOPSIS:
    #include "toolbox.h"
    double bcd_to_double( void *buf, unsigned length, int digits );

DESCRIPTION:
    The bcd_to_double() function will convert a buffer containing binary
    coded values to a value of type double.  Binary coded decimal values
    are typically data downloaded from a mainframe type computer.

ARGUMENTS:
    void *buf       - Address of buffer containing binary coded value.
    unsigned length - The length of the buffer.
    int  digits     - The number of digits to the right of the decimal
                      point.

RETURN VALUE:
    A value of type double.

EXAMPLE:

    #include <stdio.h>
    double bcd_to_double( void *buf, unsigned length, int digits );

    int main ( void ) {

        double rv;
        char test1[] = { 0x00, 0x12, 0x34, 0x5c };
        char test2[] = { 0x00, 0x12, 0x34, 0x56, 0x7d };

        printf( "%.2f\n", bcd_to_double( test1, sizeof(test1), 0));
        printf( "%.2f\n", bcd_to_double( test2, sizeof(test2), 2));
        return 0;
    }

---------------------------------------------------------------
double_to_bcd()
---------------------------------------------------------------
NAME:
    double_to_bcd() - Converts a value of type double to Binary Coded
                      Decimal format.

SYNOPSIS:
    #include "toolbox.h"
    int double_to_bcd(double arg, char *buf, unsigned len, unsigned digits);

DESCRIPTION:
    The double_to_bcd() function converts a numeric value of type double
    to a signed binary coded decimal format used by IBM mainframe
    computers.  The function allows the number of decimal digits to be
    specified as well as the number of significant digits to be
    specified.  The resulting binary coded decimal value is adjusted
    according to the position, if any, of the decimal point.

ARGUMENTS:
    double   arg    - The numeric double value to be converted.
    char     *buf   - The address of a buffer where the BCD format is to
                      be stored.
    unsigned len    - The number of significant digits to be stored.
    unsigned digits - The number of decimal digits to be stored.

RETURN VALUE:
    An integer value indicating the packed length of the BCD value.  A
    -1 is returned if the value can not be converted.  Reasons for a
    conversion failure are: (1) Both the len and digits arguments are
    zero, or (2) The sum of the len and digits arguments is greater than
    the number of significant digits that can be respresented by a value
    of type double.  This value is specified by the manifest constant
    DBL_DIG in the standard header file float.h.

SEE ALSO:
    bcd_to_double()

EXAMPLE:

    Double       Length     Digits    Return
    Argument     Argument   Argument  Value    Buffer
    ===================================================================
     12345.670      0          0       -1      Undetermined
     12345.670      5          0        3      12 34 5C 
     12345.670      5          1        4      01 23 45 6C 
     12345.670      4          3        4      23 45 67 0C 
     12345.678      1          2        2      56 7C 
    -12345.000      8          2        6      00 00 12 34 50 0D 
     -1234.560      5          3        5      00 12 34 56 0D 
      1234.567      1          3        3      04 56 7C 


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -