Re: Representing decimal part as regular integer on low 16 bits?
- From: "Jean-François Michaud" <cometaj@xxxxxxxxxxx>
- Date: 12 Sep 2006 12:24:45 -0700
Jean-François Michaud wrote:
Hello,
I was exploring this idea and I was wondering if anybody had any
thoughts concerning this.
I was thinking that the decimal part of a decimal number could be
directly converted to its "integer" representation on the low end of 16
bits.
0.325 would basically show up like this on the hex side within 32 bits
0x00000145
If we decide to fix decimals to 3 positions, this means that everytime
we are over 0x3E8 (decimal 1000), we transfer a unit on the integer
part of the 32 bits
0x00001450 + 0x00001450 + 0x00001450 + 0x00001450 = 0x00005140
so we transfer the unit over.
0x514 - 0x3E8 = 0x12C
0x000112C0.
Substraction would be similar.
I see that this potentially involves more manipulations, but it seems
that this way, no precision is lost, no rounding error will occur and
we don't need to convert to hex/binary representation. I haven't
explored multiplication or division much yet, but...
0x145 * 0x145 = 0x19C99 which corresponds exactly to 0.105625 (should
be 6 digits)
In the case of the fractional part, 0x145 doesn't mean the same as
0x0145
Anybody tried something like this?
Regards
Jeff
Hmmm Interresting. BCD without actually using BCD format.
Regards
Jean-Francois Michaud
.
- References:
- Representing decimal part as regular integer on low 16 bits?
- From: Jean-François Michaud
- Representing decimal part as regular integer on low 16 bits?
- Prev by Date: Re: RfD: Directories
- Next by Date: Re: LSE64 release 0.3
- Previous by thread: Representing decimal part as regular integer on low 16 bits?
- Next by thread: Re: Representing decimal part as regular integer on low 16 bits?
- Index(es):
Relevant Pages
|