41 lines
1.9 KiB
C
41 lines
1.9 KiB
C
|
/* ************************************************************************** */
|
||
|
/* _____ _ */
|
||
|
/* libg1m/bcd.h |_ _|__ _ _| |__ ___ _ _ */
|
||
|
/* | Project: libg1m | |/ _ \| | | | '_ \ / _ \ | | | */
|
||
|
/* | | (_) | |_| | | | | __/ |_| | */
|
||
|
/* By: thomas <thomas@touhey.fr> |_|\___/ \__,_|_| |_|\___|\__, |.fr */
|
||
|
/* Last updated: 2016/11/21 09:23:44 |___/ */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
#ifndef LIBG1M_BCD_H
|
||
|
# define LIBG1M_BCD_H
|
||
|
|
||
|
/* ************************************************************************** */
|
||
|
/* Type definition */
|
||
|
/* ************************************************************************** */
|
||
|
/* BCD are the main number format CASIO uses in its calculators.
|
||
|
* Each semi-byte is a digit going from 0 to 9 (0xA to 0xF aren't used).
|
||
|
* This format has the huge advantage to make 0.1 + 0.2 and 0.3 equal.
|
||
|
*
|
||
|
* The first three digits are the exponent.
|
||
|
* If the exponent is more than 500, then remove 500, and that means the
|
||
|
* number is negative.
|
||
|
* Then you have to remove 100 to have the real exponent.
|
||
|
*
|
||
|
* The other 15 digits are the mantissa. So the number is: (0,M ** E) */
|
||
|
|
||
|
struct bcd {
|
||
|
/* the BCD value itself */
|
||
|
unsigned char BCDval[9];
|
||
|
|
||
|
/* some 4-bytes alignment stuff */
|
||
|
unsigned char _align[3];
|
||
|
};
|
||
|
|
||
|
/* ************************************************************************** */
|
||
|
/* BCD utilities */
|
||
|
/* ************************************************************************** */
|
||
|
/* none yet -- TODO */
|
||
|
|
||
|
#endif /* LIBG1M_BCD_H */
|