Марина
Марина

Delphi 7 HELP (FLOAT)

Вот есть токая функция:

function NumToFloat(DWORDNum: DWORD): String;
const
EXP_BIAS = 127;
var
S: String;
CardinalFloat: Cardinal;
SingleFloat: Single;
Byte1, Byte2: Byte;
CardinalFractPart: Cardinal;
SingleFractPart: Single;
begin
CardinalFloat:= DWORDNum;
Byte1:= (CardinalFloat shr 31) and $1;
Byte2:= Byte((CardinalFloat shr 23) and $FF);
if Byte2 = $FF then
begin
Result:= 'Infinity or Nan';
end
else
if Byte2 = $00 then
begin
Result:= '0 (Zero) or Denormal';
end
else
begin
CardinalFractPart:= Cardinal( ( Cardinal(CardinalFloat shl 9) shr 9 ) );
SingleFractPart:= 1.0 +
((CardinalFractPart shr 22) and $1) * 0.5 +
((CardinalFractPart shr 21) and $1) * 0.25 +
((CardinalFractPart shr 20) and $1) * 0.125 +
((CardinalFractPart shr 19) and $1) * 0.0625 +
((CardinalFractPart shr 18) and $1) * 0.03125 +
((CardinalFractPart shr 17) and $1) * 0.015625 +
((CardinalFractPart shr 16) and $1) * 0.0078125 +
((CardinalFractPart shr 15) and $1) * 0.00390625 +
((CardinalFractPart shr 14) and $1) * 0.001953125 +
((CardinalFractPart shr 13) and $1) * 0.0009765625 +
((CardinalFractPart shr 12) and $1) * 0.00048828125 +
((CardinalFractPart shr 11) and $1) * 0.000244140625 +
((CardinalFractPart shr 10) and $1) * 0.0001220703125 +
((CardinalFractPart shr 9) and $1) * 0.00006103515625 +
((CardinalFractPart shr 😎 and $1) * 0.000030517578125 +
((CardinalFractPart shr 7) and $1) * 0.0000152587890625 +
((CardinalFractPart shr 6) and $1) * 0.00000762939453125 +
((CardinalFractPart shr 5) and $1) * 0.000003814697265625 +
((CardinalFractPart shr 4) and $1) * 0.0000019073486328125 +
((CardinalFractPart shr 3) and $1) * 0.00000095367431640625 +
((CardinalFractPart shr 2) and $1) * 0.000000476837158203125 +
((CardinalFractPart shr 1) and $1) * 0.0000002384185791015625 +
( CardinalFractPart and $1) * 0.00000011920928955078125;
SingleFloat:= Power(-1, Byte1) * Power(2.0, (Byte2 - EXP_BIAS)) * SingleFractPart;
S:= FloatToStr(SingleFloat);
end;
Result:= S;
end;

К примеру:
Я считал 4 байта из файла (это Float) в Integer.
Integer = 1058642330 а эта функция перевела в 0,600000023841858 (ну или 1069547520 в 1,5)

Помогите люди добрые, как к примеру это 0,600000023841858 перевести в 1058642330
(или 1,5 в 1069547520) или в HEX, но чтоб было 4 байта.

Очень надо, ВСЕМ ОГРОМНОЕ СПАСИБО !!!

МН
Мария Николаева

хреново на майл с форматированием кода, читать неудобно. . хех

Похожие вопросы
Где найти видеурок по Delphi 7 ???Где найти видеурок по Delphi 7 ???
Delphi 7 FileListBox
Delphi 7 PageControl
Подскажите по Delphi 7
программирование на Delphi 7
помогите по Delphi 7
Помогите. Delphi 7!!!
не понятное с DELPHI 7
Delphi 7 (Скрипт)
Delphi 7 WebBrowser.