Board index » delphi » Hex -> Decimal
Frederic
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
Frederic
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Hex -> Decimal
I'm searching for an algorithm to transform a hex string back to a
decimal number; i.e. an 8 byte string to a longint. Suppose I have the string s = 'ABCD1234'. Interpreting it as a hexadecimal value, how can I transform it into a longint? Oh, by the way... This is not homework. It's merely to fiddle a bit |
Ing. Franz Glase
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Hex -> DecimalQuoteFrederic wrote: chapter "numerics", "RadixVal" or "ValRadix". Forgot the name :-) Regards, Franz Glaser |
Horst Kraem
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Hex -> DecimalOn Mon, 30 Nov 1998 16:32:02 +0100, Frederic <frede...@rz-online.de> wrote: Quote> I'm searching for an algorithm to transform a hex string back to a contain "decimal numbers". They contain binary numbers ;-) The procedure VAL does what you want. It is used by the system when const Regards |
Osmo Ronkan
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Hex -> DecimalIn article <3662BA72.95D1...@rz-online.de>, QuoteFrederic <frede...@rz-online.de> wrote: x:longint; ... Val('$'+s,x,err); Osmo |
Papai Andra
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Hex -> DecimalQuote> I'm searching for an algorithm to transform a hex string back to a Just put a '$' before the hex number and convert it with val(). :) Andras |
Timo Sal
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Hex -> DecimalUpdate draft: -Subject: Converting the number base 42. ***** A: Here is one possibility A2: In the case of converting a hexadecimal string into a decimal All the best, Timo .................................................................... Spam foiling in effect. My email filter autoresponder will return a |
Dr John Stockto
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Hex -> DecimalJRS: In article <7412er$...@loisto.uwasa.fi> of Tue, 1 Dec 1998 17:36:59 in news:comp.lang.pascal.borland, Timo Salmi <t...@UWasa.Fi> wrote: Quote>Update draft: to "j", for those with ageing eyes! *), it's still inelegant to do all those multi-shifts. How about (untested, but very like part of my pas-opts.htm; over-short function LB(D : longint) : string ; ? -- |
Pedt Scrag
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Hex -> DecimalIn article <1KpXZfBsfHZ2E...@merlyn.demon.co.uk>, Dr John Stockton <j...@merlyn.demon.co.uk> writes Quote>JRS: In article <7412er$...@loisto.uwasa.fi> of Tue, 1 Dec 1998 - Hide quoted text - - Show quoted text - Quote>> binar[0] := chr(32); - saves about 3 bytes of code if FillChar is removed from LBINFN but no speed saving on execution. Personally I'd go for: function LB(d : longint) : String; Although no byte saving on Timo's version without FillChar, it does -- Kill one Scottish midge and a million will come to the funeral |
Timo Sal
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Hex -> DecimalIn article <OV6yiIA2KJZ2E...@pedt.demon.co.uk>, Pedt Scragg <newsmas...@pedt.demon.co.uk> wrote: :>> FillChar (binar, SizeOf(binar), ' '); :On this occasion FillChar is not needed True, but I prefer to put it there routinely, especially in the FAQ. : function LB(d : longint) : String; I'll include this as a joint alternative from John and you. All the best, Timo .................................................................... Spam foiling in effect. My email filter autoresponder will return a |