Jump to content

[Pascal in Delphi]System to system

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
Krad

Krad

    Newbie

  • Members
  • Pip
  • 2 posts
Hi! I can't do a simple program in Pascal... I need to program which change any system for example dec, hex... to other system for example binary code, but (in program) i must give this system:

begginig
"Please give a system:" for example 2
"Please give second system:" for. ex. 16
"Give me a value:" 01001

"Value is..."

And now it change me from binary to 16 system a value 01001.
How it write?
Sorrry for my English but it isn't good in computers. Thanks!

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
First question: can you do this with a pencil and paper?
When I did this program, my strategy was go from base A to decimal to base B.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Krad

Krad

    Newbie

  • Members
  • Pip
  • 2 posts
Uhm... no. I do it in Delphi.
Code for change a other system to binary:

program NaDowolnySystem;

{$APPTYPE CONSOLE}

const
SYSTEM='0123456789ABCDEFGHIJKLMNOPRSTUWXYZ';
var
wynik:string;
NaSystem,JakaLiczba:integer;
begin
  repeat
    write('What system (max 34): ');
    readln(NaSystem);
  until NaSystem in [2..34];
  write('Give value: ');
  readln(JakaLiczba);
  repeat
    wynik:=SYSTEM[JakaLiczba mod NaSystem+1] + wynik;
    JakaLiczba:=JakaLiczba div NaSystem;
  until JakaLiczba=0;
  writeln('Wynik: ',wynik);
  readln;
end.

But I need program in two side - from other system to other (not binary) AND change loop 'repeat' on FOR.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Krad, my point was that if you can't do the conversions by hand, then you will NEVER be able to program the conversions. Do you know how to do the conversions by hand?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
t3chn0n3rd

t3chn0n3rd

    Newbie

  • Members
  • Pip
  • 2 posts
Are you using a borland compiler?

#6
olegator

olegator

    Newbie

  • Members
  • Pip
  • 1 posts
If you using a borland compiler, you can use function: IntToBin, IntToHex, BinToHex etc.