Jump to content

Перевод чисел из одной системы счисления в другую


 Share

Recommended Posts

Очень нужна помощь, ГОРЮ!!!!!!!

Помогите пожалуйста!!

Мне нужно

разработать функцию, которая представляла бы значение поля формы в одном из трех кодов счисления: 2, 10, 16. Используя эту функцию представить значение этого поля при щелчке мыши в одном из этих трех кодов, выбранном из группы радиокнопок.

Проблемы возникли с переводом из одной системя счисления в другу.

подскажите как это сделать в ДЕЛЬФИ????

Если что пишите мне на мыло: era666@bk.ru

Буду очнь благодарна за помощь!!=)

Link to comment
Share on other sites

Нашел в google этого

http://delphi.about.com/od/mathematics/a/baseconvert.htm

Из 10 в 16 встроенная функция: IntToHex

Надо SysUtils подключить

Остальние:

function HexToInt(HexNum: string): LongInt;begin  Result:=StrToInt('$' + HexNum);end;unction IntToBin ( value: LongInt; digits: integer ): string;beginresult := StringOfChar ( '0', digits );while value > 0 do begin  if ( value and 1 ) = 1 then	result [ digits ] := '1';  dec ( digits );  value := value shr 1;end;end;function BinToInt(Value: String): LongInt;var i: Integer;begin Result:=0;//remove leading zeroes while Copy(Value,1,1)='0' do  Value:=Copy(Value,2,Length(Value)-1);//do the conversion for i:=Length(Value) downto 1 do  if Copy(Value,i,1)='1' thenResult:=Result+(1 shl (i-1));end;
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...