# Board index » delphi » How to convert large hex numbers to decimal

## How to convert large hex numbers to decimal

Can anyone demonstrate how to convert a large hexadecimal number to decimal.
For example how would I convert 8000F58000104CC6 ?

Thanks for any help
Tony

-----------== Posted via Deja News, The Discussion Network ==----------

## Re:How to convert large hex numbers to decimal

##### Quote
On Mon, 08 Mar 1999 07:41:49 GMT, tonyrobin...@my-dejanews.com wrote:
>Can anyone demonstrate how to convert a large hexadecimal number to decimal.
>For example how would I convert 8000F58000104CC6 ?

If you have Delphi 4, use an Int64 and just call StrToInt. (Preface the
hex string with '\$' to tell StrToInt that it's hex.)
--
Ray Lischner (http://www.tempest-sw.com/)
Author of "Hidden Paths of Delphi 3: Experts, Wizards, and the Open Tools API"

## Re:How to convert large hex numbers to decimal

6h -> 6  * 1
+              C0h -> 12 * 16
+             C00h -> 12 * 16*16
+            4000h -> 4  * 16*16*16
+           00000h -> 0  * 16^4
+          100000h -> 1  * 16^5
+         0000000h -> 0  * 16^6
+        00000000h -> 0  * 16^7
+       000000000h -> 0  * 16^8
+      8000000000h -> 8  * 16^9
+     50000000000h -> 5  * 16^10
+    F00000000000h -> 15 * 16^11
+   0000000000000h -> 0  * 16^12
+  00000000000000h -> 0  * 16^13
+ 000000000000000h -> 0  * 16^14
8000000000000000h -> 8  * 16^15
----------------------------
(8000F58000104CC6)h -> 9223641966960463046

## Re:How to convert large hex numbers to decimal

You could use the windows calculator Scientific wiew :)

--
Regards
Kai Inge

{When I realized the difference between estimated time used and real time
used - I realized that the life is going to be too short.}

##### Quote
tonyrobin...@my-dejanews.com wrote in message

<7bvuvs\$f4...@nnrp1.dejanews.com>...
##### Quote
>Can anyone demonstrate how to convert a large hexadecimal number to
decimal.
>For example how would I convert 8000F58000104CC6 ?

>Thanks for any help
>Tony

>-----------== Posted via Deja News, The Discussion Network ==----------

## Re:How to convert large hex numbers to decimal

JRS:  In article <7bvuvs\$f4...@nnrp1.dejanews.com> of Mon, 8 Mar 1999
07:41:49 in news:comp.lang.pascal.delphi.misc, tonyrobinson@my-

##### Quote
dejanews.com wrote:
>Can anyone demonstrate how to convert a large hexadecimal number to decimal.
>For example how would I convert 8000F58000104CC6 ?

This is Pascaloid pseudocode, not necessarily strict Delphi :

D := 0 ;
for J := 1 to Length(S) do
D := 10*D + Pred(Pos(S[J], '0123456789ABCDEF')) ;

For large numbers, you will either need to make D a float and accept
limited accuracy, or implement your own long decimal type and
operations.  My Web programs/longcalc.pas includes long arithmetic.

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v4.00    MIME.
Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
<A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.

## Re:How to convert large hex numbers to decimal

##### Quote

>For large numbers, you will either need to make D a float and accept

Make D a Comp type (64 bit)

## Re:How to convert large hex numbers to decimal

JRS:  In article <u9#7Utaa#GA.162@upnetnews03> of Mon, 8 Mar 1999
16:28:22 in news:comp.lang.pascal.delphi.misc, Bruce Roberts

##### Quote

>>For large numbers, you will either need to make D a float and accept

>Make D a Comp type (64 bit)

Only for small values of large; but, of course, comp is really a sort of
semi-float type.

If the answer fits in comp, the following technique, tested in BP7,
should work, though if a 64-bit fixed type is available the question
becomes so trivial that I presume it would not have been necessary. :

const A :
record case byte of 1: (C : comp) ; 2: (Lo, Hi : longint) end =
(Lo : \$00104CC6; Hi : \$8000F580) ;
begin writeln(A.C:40:0) ;