number conversion in pascal 
Author Message
 number conversion in pascal

Quote:

> hello all!

> to anyone who knows Pascal: how can you convert hexadecimal number into
> denary using turbo pascal 7? (and vice-versa)?
> is there a data type suitable for hexadecimal numbers?

> thanks in advance....

> mel

Val('&H'+yourstring,I,C);

Function HexString(W : Word):String;
Const HexC : Array[0..15] of Char = '0123456789ABCDEF';
Var I : Integer;
    S : String;
Begin
  S := '0000';
  for I := 4 downto 1 do
    Begin
      S[I] := HexC[W and $0F];
      W := W shr 4;
    End;
  HexString := S;
End;
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation

http://www.*-*-*.com/ ~franzglaser/ http://www.*-*-*.com/



Wed, 18 Jun 1902 08:00:00 GMT  
 number conversion in pascal
hello all!

to anyone who knows pascal: how can you convert hexadecimal number into
denary using turbo pascal 7? (and vice-versa)?
is there a data type suitable for hexadecimal numbers?

thanks in advance....

mel



Wed, 18 Jun 1902 08:00:00 GMT  
 number conversion in pascal


Quote:

>> hello all!

>> to anyone who knows pascal: how can you convert hexadecimal number into
>> denary using turbo pascal 7? (and vice-versa)?
>> is there a data type suitable for hexadecimal numbers?

>> thanks in advance....

>> mel

>Val('&H'+yourstring,I,C);

That should be val('$'+yourstring,i,c);

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 number conversion in pascal

Quote:

> is there a data type suitable for hexadecimal numbers?

Surely. Byte,ShortInt,Integer,Word,LongInt.

Any of those are suitable :-)

--
main(C,f,s){for(/** gcc sig.c;a.out>/dev/audio ## http://iki.fi/bisqwit/ **/
write(C=0,"(C)Bisqwit\n",11);f=99;++C){for(s="+%7%+%7%5%4%2%457%0%0%754%2%+"
"%%%5%542%457%0%0%042%2#+%!#0%+%$%%%"[C&63];s--;f=f*89/84);for(s=999+99*(C&2
);--s;putchar(((s*(f-776?f:0)&32767)*s/199999+39-(C&2?rand()%s/24:0))/16));}}



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Numbers Conversion

2. Conversion from numbers to words

3. base conversion of large numbers

4. base conversion of large numbers

5. Number conversions

6. Tutorial on number conversion, any base

7. Help with Number Conversions

8. Program for number conversion, bases 2..72

9. Tutorial on number conversion, any base

10. Program for number conversion, bases 2..72

11. Need Pascal to Delphi or C++ or Pascal 32-bit conversion advice

12. "C++" to Turbo Pascal Conversion

 

 
Powered by phpBB® Forum Software