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 into 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 8:32:08 PM
embarcadero.delphi.win32 2183 articles. 0 followers. Follow

7 Replies
1553 Views

Similar Articles

[PageSpeed] 43

> {quote:title=Mehmet Fide wrote:}{quote}
> Hi,
> 
> There is one bcd number has 20 digit. But it doesn't fit into 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.

Google for BigInteger or BigDecimal Variant Delphi
Here is one - http://code.google.com/p/delphi-spring-framework/source/browse/trunk/Source/Core/Numerics/Spring.Numerics.BigDecimal.pas?r=258
0
An
2/22/2012 8:52:57 PM
> Google for BigInteger or BigDecimal Variant Delphi
> Here is one - 
> http://code.google.com/p/delphi-spring-framework/source/browse/trunk/Source/Core/Numerics/Spring.Numerics.BigDecimal.pas?r=258

Nice library. Thanks for it.
But still I wonder isn't there 128 bit native support in 64 bit mode?
0
Mehmet
2/22/2012 11:30:54 PM
"Mehmet Fide" wrote
> There is one bcd number has 20 digit. But it doesn't fit into 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 practical way to do this?

Mehmet,
If it is just this one case, I would just make a string-in, string-out function
with my own big-integer accumulator from an array of three UInt32
variables and do a multiply x 10 and add for each new input decimal
digit. The second step, shifting the 4-bit nibbles into hexadecimal is
easy.
HTH, JohnH
0
John
2/23/2012 1:50:08 AM
Mehmet Fide wrote:

> Hi,
> 
> There is one bcd number has 20 digit. But it doesn't fit into 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.

http://rvelthuis.de/programs/decimals.html

My Decimal type's mantissa can hold 96 bits. Convert the BCD to a
string (this is simple, as each nibble contains one digit), assign it
to a Decimal and get the bytes from the Decimal. These can then be
turned into a hex string again.

How is the BCD stored? Let's assume 10 bytes with the most significant
digit in the top 4 bits of the first byte:

  S := '';
  for I := 0 to 9 do
    S := S + Char(Ord('0') + Bytes[I] shr 4) + 
             Char(Ord('0') + Bytes[I| and $0F);

If the order is reverse (most significant digit in last byte), you can
do:

  S := '';
  for I := 0 to 9 do
    S := Char(Ord('0') + Bytes[I] shr 4) + 
         Char(Ord('0') + Bytes[I| and $0F) + S;

Now, if you have the number in a string (let's call it S) already, then
you don't need to do any of the above:

  var
    MyBytes: TBytes;

  MyDecimal := S; // converts string representation to Decimal with
                  // mantissa containing 96 bit number and scale of 0.
  MyBytes = MyDecimal.GetBytes; // lower 12 bytes (96 bits) are
mantissa

Now ignore the top Longword and use the remaining 96 bits to get your
hex:

  const 
    HexChars: array[0..15] of Char = '0123456789ABCDEF';
  var
    Hex: string;

  ...

  Hex := '';
  for J := 0 to 11 do
    Hex := HexChars[MyBytes[I] shr 4] + 
           HexChars[MyBytes[I] and $0F] + Hex; 

That will give you a 24 digit hex string. 
-- 
Rudy Velthuis

"He would make a lovely corpse."
 -- Charles Dickens (1812-1870)
0
Rudy
2/23/2012 8:00:10 PM
Rudy Velthuis (TeamB) has brought this to us :
>
> http://rvelthuis.de/programs/decimals.html

Hi,

Thanks a lot, this unit did the job directly :)

{Delphi}
function BytesToHex(aSource: TBytes): string;
begin
  SetLength(Result, Length(aSource) * 2);
  if Length(aSource) > 0 then
    BinToHex(aSource[0], PChar(Result), Length(aSource));
end;

procedure TForm1.Button1Click(Sender: TObject);
Var
  D: Decimal;
  B: TBytes;
begin
 D := '62636944367208999885';
 B := D.GetBytes;
 Memo1.Lines.Add(BytesToHex(B));
end;
{Delphi}
0
Mehmet
2/23/2012 10:39:26 PM
Mehmet Fide wrote:

> Rudy Velthuis (TeamB) has brought this to us :
> > 
> > http://rvelthuis.de/programs/decimals.html
> 
> Hi,
> 
> Thanks a lot, this unit did the job directly :)
> 
> {Delphi}
> function BytesToHex(aSource: TBytes): string;
> begin
>   SetLength(Result, Length(aSource) * 2);
>   if Length(aSource) > 0 then
>     BinToHex(aSource[0], PChar(Result), Length(aSource));
> end;
> 
> procedure TForm1.Button1Click(Sender: TObject);
> Var
>   D: Decimal;
>   B: TBytes;
> begin
>  D := '62636944367208999885';
>  B := D.GetBytes;
>  Memo1.Lines.Add(BytesToHex(B));
> end;
> {Delphi}

YAY!

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

"I hear Glenn Hoddle has found God. That must have been one hell
 of a pass." -- Bob Davies.
0
Rudy
2/24/2012 10:44:35 AM
> What is the pratical way to do this?

20 digit binary requires 66 bits. bcd stores 2 digits in one byte. Delphi 
supports TBCD type (unit FMTBCD).

the program below runs fine in XE2

Ad Franse

program testfmtbcd;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  fmtbcd,
  variants;

var length  : TBCD;
var width   : TBCD;
var height  : TBCD;
var content : TBCD;

var fs      : TFormatSettings;
var v       : variant;

begin
  fs                  := TFormatSettings.Create;
  fs.DecimalSeparator := '.';

  length  := strtoBCD('62636944367208999885' );
  width   := strtoBCD('1234567890.123456789', fs ) / 100.0;       // note the decimal point
  height  := 987654321098765.4 / 987654.3;
  content := length * width * height;

  writeln( 'l=' + formatbcd( '##############################.###################', length ));
  writeln( 'w=' + formatbcd( '##############################.###################', width  ));
  writeln( 'h=' + formatbcd( '##############################.###################', height ));
  writeln( 'c=' + formatbcd( '##############################.###################', content ));
  if content <> strtobcd( formatbcd( '##############################.###################', content + 1 )) then  // localized decimal point
    begin
      writeln( '*** The values of content and strtoBCD( formatBCD( ''' + formatbcd( '##############################.###################', content ) + ''')) are different' );
    end;

end.
0
Ad
2/27/2012 9:21:10 AM
Reply:

Similar Artilces:

Delphi 64 Bit released just in time for Windows to be 128 Bit ...
Ok - the title is a little provocative - but it might be close ;) This link is to an article the claims that the next Windows version will be 128 Bit. Which would be Win8 - and if not that version then definitely Win 9. http://arstechnica.com/microsoft/news/2009/10/microsoft-mulling-128-bit-versions-of-windows-8-windows-9.ars I realize that Delphi 64 bit should be out this year (or so I hope!) - and that the next windows is a few years away - but I hope the folks at Emb. are already planning for the 128 version when they do the 64 bit version... Bradley MacDonald brad_AT_tim...

SQL 8 support for 64 bit OS and 64 BIT OS, 64 BIT BUS Support, technical white paper, documentation, examples and success stories for SQL 8 if any please
SQL Anywhere Associates!! Is SQL 8 support 64 bit OS and 64 BIT OS, 64 BIT BUS Support, technical white paper, documentation, examples and success stories for SQL 8 if any please.... Thanks Vairam I believe that SQL Anywhere Studio is currently only released in a 32-bit format. TO the extent that 32-bit applications can run on a 64-bit OS, you can use ASA on a 64-bit system. -- Reg Domaratzki, Sybase iAnywhere Solutions Certified SQL Anywhere Associate Please reply only to the newsgroup ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm -> Cho...

SQL 8 support for 64 bit OS and 64 BIT OS, 64 BIT BUS Support, technical white paper, documentation, examples and success stories for SQL 8 if any please
SQL Anywhere Associates!! Is SQL 8 support 64 bit OS and 64 BIT OS, 64 BIT BUS Support, technical white paper, documentation, examples and success stories for SQL 8 if any please.... Thanks Vairam Is there any particular 64 bit OS that you are interested in hearing about? - Mark VS Vairam wrote: > > SQL Anywhere Associates!! > Is SQL 8 support 64 bit OS and 64 BIT OS, 64 BIT BUS Support, technical > white paper, documentation, examples and success stories for SQL 8 if any > please.... > > Thanks > > Vairam WINDOWS all flavours...

Excel 64-bit and Delphi 32-bit
Hi, Any known issues with using Excel 2010 64-bit with a Delphi 32-bit app (Delphi 2009) My app uses the ExcelXP TExcelApplication object and nothing real fancy. I basically opens Excel, gets a list of all the ranges, and then updates the cells. It works fine with Excel 2007 but I have one customer who is reporting problems and he has Excel 2010 64-bit. Also, is there a way for my app to determine if Excel is 32 or 64-bit so that I can log an appropriate message. -- Bob Small I think one the main points of the new Delphi 64-bit compiler was that it was required to be able...

Delphi 64 bit / Future Direction of Delphi
I am responding to the various requests for 64 bit and the discussion about the future direction of Delphi. I have a small company - we write software for new and used auto dealerships - sales and finance - coming out with accounting now and parts and service in the next few years. Our customers don't care about 32 bit vs 64 bit, etc. They want me to provide simple and convenient solutions to make their jobs easier. We have stuck with Delphi 5 for many years - I should have upgraded 5 years ago but it did the job. We are now in the early stages of a significant up...

XML for Delphi XE6 32-bit/64-bit
I am looking for a straight-forward no frills XML library or component that allows me to easily form an XML file and to parse it easily as a means to transfer text (could be long and lengthy) information back and forth between applications. I would appreciate any recommendation of such a resource. Or maybe XML is not a good option for my application? Thanking you all in advance. Andy Andy wrote: > I am looking for a straight-forward no frills XML library or component > that allows me to easily form an XML file and to parse it easily as a > means to transfer text (co...

Does the next version of Delphi supports 64 bits or...
....does the next version of Delphi only contain a parallel threading library? Hi Okkie, > ...does the next version of Delphi only contain a parallel threading library? I guess we'll know when The Roadmap (tm) gets updated ;-) Groetjes, Bob Swart -- Bob Swart Training & Consultancy (eBob42.com) Forever Loyal to Delphi CodeGear Technology Partner -- CodeGear RAD Studio Reseller (BeNeLux) Delphi Win32 & .NET books on Lulu.com: http://stores.lulu.com/drbob42 Personal courseware + e-mail support http://www.ebob42.com/courseware Blog: http://www.drbob4...

No native 64-bit support in Delphi 2010
I just noticed that quality central shows the bug report requesting native 64 bits support (yes the one with almost 1000 votes) as closed: http://qc.embarcadero.com/wc/qcmain.aspx?d=7324 Now that is great news... Uuuh, well, that is until you read the resolution: "Deferred to Next Rel". Codegear's CEO was not lying when he told us that native 64-bit support is not the top priority anymore. And can someone with privileges please reopen it. Jan Derk Jan Derk wrote: > I just noticed that quality central shows the bug report requesting > native 64 bits s...

32 bit Delphi Active X Control on 64 Bit machines
I'm using BDS 2006 and created a very simple Active X control ( COM ) ocx file that does nothing but return a string in a property. Placing the control on a .net application that contains a label reflecting the property builds and runs beautifully in 32 bit Windows Vista. Moving the application to Windows 7 64 bit fails. Debugging shows it doesn't even get to initialization. Is it possible to use COM through syswow64? <Steven Davis> wrote in message news:225825@forums.embarcadero.com... > I'm using BDS 2006 and created a very simple Active X control > ( COM ) ...

Running 64 bit console application from a 32 bit Delphi GUI app?
I want to improve the usability of a 64 bit command line program so it can be handled by fairly inexperienced users. For this I need a normal Delphi program to have data specifiers etc, which in the end results in a command file for the console application. This is no big deal. The problem is the following: ------------------------------ 1) Can I start the 64 bit console app in Windows7X64 using the CreateProcess API like I am used to for 32 bit applications? Or are 64 bit programs different? 2) And if that is possible, can I somehow snatch what it sends to standard out (the co...

64 bit cpu // 64 bit Os version // 64 bit powerbuilder?
Hi guys, Does anyone know if Powebuilder is available in 64 bit? Kind regards A 64-bit version of PB does not (yet) exist. -- HTH Arnoud Url: http://www.gloriant.be Also check out my PB Reference site : http://www.pbinfo.be "Gunther Huygens" <ghuygens@be.xrt.com> wrote in message news:eoSjDRaCDHA.331@forums-1-dub... > Hi guys, > > Does anyone know if Powebuilder is available in 64 bit? > > Kind regards > > > > Since there are no OS Windows 64 bits, i wonder how it could be possible. Since there is a 64 bi...

Occasional errors with 32-bit Delphi 7 application on Windows 7 64-bit
Hi, I have a 32-bit Delphi 7 application which was deployed on some machines with Windows 7 64-bit. The application occasionally displays errors such as: "Error reading ppDBText37.Border.Color: Invalid property value" or "Error reading Label24.Font.Ch: Property Ch does not exist" (here the name "Charset" was apparently truncated to "Ch") I checked how those properties are declared on the form where the errors occurred, and all seems ok: - First form (where "Error reading ppDBText37.Border.Color: Invalid property value" occurs): ...

Call 64bit dll's function from 32 bit delphi code on 64 bit OS
Is there any way or trick to call a function in 64 bit DLL from Delphi code? Any hardware manufacturer must compile their device drivers into 64bit code for 64 bit OS. So for example, graphic driver from NVidia is compiled to 64bit code for 64bit OS. Question is how to load 64 bit dll from 32 bit delphi code and call such function? I hope somebody has already dealing with that. Thanks > is how to load 64 bit dll from 32 bit delphi code and call such function? http://msdn.microsoft.com/en-us/library/aa384249(VS.85).aspx http://blogs.msdn.com/oldnewthing/archive/2008/10/20/9...

Web resources about - is there a support for 128 bit at 64 bit delphi? - embarcadero.delphi.win32

Air Force Civil Engineer Support Agency - Wikipedia, the free encyclopedia
AFCESA began as the Civil Engineer Construction Operations Group at Wright-Patterson Air Force Base , Ohio in 1966. Two years later, the new ...

Photoshop Fix for iPad Pro now supports Apple Pencil tilt shading & pressure detection
Adobe’s recently launched Photoshop Fix app has been updated this week to add further support for Apple Pencil on iPad Pro . The image editing ...

Satire as US voters support bombing Aladdin's Agrabah
Social media sends up some 30 percent of Republicans who say they would support bombing the fictional Disney nation.

Adobe’s Photoshop Fix gets enhanced support for the Apple Pencil
... popular application designed to bring advanced photo-editing functionality to the iPad Pro, has just received an update adding enhanced support ...

"U.S. Support of Gay Rights in Africa May Have Done More Harm Than Good."
A NYT headline — the thud of recognition of unintended consequences. “The U.S. support is making matters worse,” said Mike, 24, a university ...

Sheldon Adelson Will Support Whoever Wins GOP Primary–Even Trump
... been decided. From Bloomberg Business : Casino mogul Sheldon Adelson acknowledged presidential candidate Donald Trump’s “incredible” support ...

300 US Lawmakers Support 50% Clean Energy By 2050
... to a central focus point due to the Paris climate change talks that just took place, and they all signed a [&hellip 300 US Lawmakers Support ...

Former NFL Player Shawne Merriman Supports Donald Trump
Former NFL Player Shawne Merriman Supports Donald Trump

This week at progressive states blogs: No support from SD's senators for boosting Indian vote
This week in progressive state blogs is designed specifically to focus attention on the writing and analysis of people focused on their home ...

Local residents rally to support Riverheads teacher
The Daily Progress Local residents rally to support Riverheads teacher The Daily Progress Hatred and negativity on Facebook: that's what inspired ...

Resources last updated: 12/20/2015 7:23:42 PM