is there a support for 128 bit at 64 bit delphi?

Hi,

There is one bcd number has 20 digit. But it doesn't fit to 64 bit. It 
needs 66 bit to store :/ Anyway I need to convert this 20 digit number 
to hex format. I mean, input is 20 digit bcd number as string, output 
should be hexadecimal number as string.

What is the pratical way to do this?

Thank you.
0
Mehmet
2/22/2012 6:20:24 PM
embarcadero.delphi.non-tech 5933 articles. 1 followers. Follow

9 Replies
1088 Views

Similar Articles

[PageSpeed] 19

Am 22.02.2012 19:20, schrieb Mehmet Fide:
> Hi,
> 
> There is one bcd number has 20 digit. But it doesn't fit to 64 bit. It 
> needs 66 bit to store :/ Anyway I need to convert this 20 digit number 
> to hex format. I mean, input is 20 digit bcd number as string, output 
> should be hexadecimal number as string.
> 
> What is the pratical way to do this?
> 
> Thank you.


Hello,

I'd suggest you reask this question in the language group as you'll get
more answers over there:

embarcadero.public.delphi.language.delphi.win32

Follow up for NNTP readers set.

Greetings

Markus
0
Markus
2/22/2012 7:34:27 PM
> {quote:title=Mehmet Fide wrote:}{quote}
> Hi,
> 
> There is one bcd number has 20 digit. But it doesn't fit to 64 bit. It 
> needs 66 bit to store :/ Anyway I need to convert this 20 digit number 
> to hex format. I mean, input is 20 digit bcd number as string, output 
> should be hexadecimal number as string.
> 
> What is the pratical way to do this?
> 
> Thank you.

You can hack your way around Extended (80bits) type.
But that's simply too ugly.
0
arthur
2/23/2012 7:17:11 PM
"Mehmet Fide" <aa@off.net> wrote in message 
news:447740@forums.embarcadero.com...

> I mean, input is 20 digit bcd number as string

How is that different from a 20 digit number as a string?
0
Uffe
2/23/2012 7:38:37 PM
Uffe Kousgaard wrote:

> "Mehmet Fide" <aa@off.net> wrote in message
> news:447740@forums.embarcadero.com...
> 
> > I mean, input is 20 digit bcd number as string
> 
> How is that different from a 20 digit number as a string?

Indeed. I assume he has a string, not a BCD number. 

FWIW, for Mehmet: BCD means binary coded digit and it usually stores
one decimal digit (0..9) per nibble (4 bits), or two digits per byte.
The values $A..$F are simply never used.)

To turn that into a string you simply take each nibble and add Ord('0')
to it to get a Char. The top nibble of a Byte can be found by

  TopNibble := TheByte shr 4;

And the bottom nibble by:

  BottomNibble := TheByte and $0F;

http://en.wikipedia.org/wiki/Binary-coded_decimal

So decimal 123456 is either coded as $12 $34 $56 or reverse (small
endianness), i.e. $56 $34 $12.
-- 
Rudy Velthuis

"All propaganda must be so popular and on such an intellectual
 level, that even the most stupid of those toward whom it is
 directed will understand it ... Through clever and constant
 application of propaganda, people can be made to see paradise
 as hell, and also the other way around, to consider the most
 wretched sort of life as paradise."
 -- Adolf Hitler
0
Rudy
2/23/2012 9:29:37 PM
After serious thinking Rudy Velthuis (TeamB) wrote :
> Uffe Kousgaard wrote:
>
>> "Mehmet Fide" <aa@off.net> wrote in message
>> news:447740@forums.embarcadero.com...
>> 
>>> I mean, input is 20 digit bcd number as string
>> 
>> How is that different from a 20 digit number as a string?
>
> Indeed. I assume he has a string, not a BCD number. 
>
> FWIW, for Mehmet: BCD means binary coded digit and it usually stores
> one decimal digit (0..9) per nibble (4 bits), or two digits per byte.
> The values $A..$F are simply never used.)

Yes I know that, sorry for confusion. Because it is very easy to 
convert bcd numbers to string representations or vice-versa just by 
adding or subtracting 48, I’ve used this terminology which was a 
mistake actually. My input is as string not BCD :)
0
Mehmet
2/23/2012 10:06:39 PM
Mehmet Fide wrote:

>  My input is as string not BCD :)

Then really try my Decimal type in my Decimals unit. You can directly
assign a string to it, and you can get its data using the GetBytes
function:

  const 
    HexChars: array[$00..$0F] of Char = '0123456789ABCDEF';

  ...

  MyDecimal := S;
  Bytes := MyDecimal.GetBytes;
  for I := 0 to 11 do
    Hex := HexChars[Bytes[I] shr 4] + 
           HexChars[Bytes[I] and $0F] + Hex;

  http://rvelthuis.de/zips/decimals.zip

-- 
Rudy Velthuis

Sausage Principle: People who love sausage and respect the law 
should never watch either one being made.
0
Rudy
2/23/2012 10:19:19 PM
Op 22-2-2012 19:20, Mehmet Fide schreef:
> Hi,
>
> There is one bcd number has 20 digit. But it doesn't fit to 64 bit. It
> needs 66 bit to store :/ Anyway I need to convert this 20 digit number
> to hex format. I mean, input is 20 digit bcd number as string, output
> should be hexadecimal number as string.
>
> What is the pratical way to do this?
>
> Thank you.

Check TBCD (FMTBCD)
I could not find examples.

20 digits in 66 bits is binary.
20 digits in 11 bytes is bcd (2 digits per byte + sign)

Ad Franse
0
Ad
2/23/2012 10:42:46 PM
Rudy Velthuis (TeamB) expressed precisely :
>   MyDecimal := S;
>   Bytes := MyDecimal.GetBytes;
>   for I := 0 to 11 do
>     Hex := HexChars[Bytes[I] shr 4] + 
>            HexChars[Bytes[I] and $0F] + Hex;
>
>   http://rvelthuis.de/zips/decimals.zip

Hi Rudy,

As I indicated on the delphi.win32, this unit worked for me directly. 
Thanks a lot again.

Mehmet.
0
Mehmet
2/23/2012 10:43:24 PM
Mehmet Fide wrote:

> Rudy Velthuis (TeamB) expressed precisely :
> >   MyDecimal := S;
> >   Bytes := MyDecimal.GetBytes;
> >   for I := 0 to 11 do
> >     Hex := HexChars[Bytes[I] shr 4] + 
> >            HexChars[Bytes[I] and $0F] + Hex;
> > 
> >   http://rvelthuis.de/zips/decimals.zip
> 
> Hi Rudy,
> 
> As I indicated on the delphi.win32, this unit worked for me directly. 
> Thanks a lot again.

Oh, cool. I hadn't seen the other reply.

-- 
Rudy Velthuis [TeamB]        http://rvelthuis.de

"Every day I get up and look through the Forbes list of the 
 richest people in America. If I'm not there, I go to work."
 -- Robert Orben
0
Rudy
2/24/2012 8:08:13 AM
Reply: