Вверх ↑
Ответов: 2059
Рейтинг: 131
#1: 2022-06-30 10:32:13 ЛС | профиль | цитата
andrestudio писал(а):
String->HEX->Single Шедевр

Double->HEX.....HEX->Single

По теме:
Add(MainForm,4098603,210,91)
{
Width=291
Height=530
}
Add(InlineCode,9268460,378,168)
{
WorkPoints=#6:doWork|
EventPoints=#6:onTrue|0:|
DataPoints=#6:Param1|6:Param2|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|21:uses Share,Kol,Debug;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|8: |10: public|21: Param1: THI_Event;|22: Param2: THI_Event; |19: onTrue: THI_Event;|3: |49: Procedure doWork(var _Data:TData; Index:Word); |0:|5: end;|0:|2: |15: implementation|1: |47:function Str2Single( const S: String ): Single;|15:var I: Integer;|19: M, Pt: Boolean;|15: Sn: Single;|16: Ex: Integer;|5:begin|16: Result := 0.0;|22: if S = '' then Exit;|13: M := FALSE;|9: I := 1;|22: if S[ 1 ] = '-' then|7: begin|14: M := TRUE;|13: Inc( I );|6: end;|32: if S[ 1 ] = '+' then Inc( I );|14: Pt := FALSE;|12: Sn := 1.0;|27: while I <= Length( S ) do|7: begin|18: case S[ I ] of|46: '.': if not Pt then Pt := TRUE else break;|28: '0'..'9': if not Pt then|77: Result := Result * 10.0 + Integer( S[ I ] ) - Integer( '0' )|18: else|19: begin|31: Sn := Sn * 0.1;|77: Result := Result + (Integer( S[ I ] ) - Integer( '0' )) * Sn;|18: end;|19: 'e', 'E': begin|53: Ex := Str2Int( CopyEnd( S, I + 1 ) );|56: Result := Result * IntPower( 10.0, Ex );|22: break;|18: end;|15: else break;|8: end;|13: Inc( I );|6: end;|11: if M then|22: Result := -Result;|4:end;|0:|46:function Extended2Str4( E: Extended ): String;|75: function UnpackFromBuf( const Buf: array of Byte; N: Integer ): String;|28: var I, J, K, L: Integer;|9: begin|29: SetLength( Result, 8 );|13: J := 1;|28: for I := 7 downto 0 do|11: begin|28: K := Buf[ I ] shr 4;|44: Result[ J ] := Char( Ord('0') + K );|17: Inc( J );|29: K := Buf[ I ] and $F;|44: Result[ J ] := Char( Ord('0') + K );|17: Inc( J );|10: end;|0:|44: Assert( Result[ 1 ] = '0', 'error!' );|29: Delete( Result, 1, 1 );|0:|20: if N <= 0 then|11: begin|22: while N < 0 do|13: begin|33: Result := '0' + Result;|19: Inc( N );|12: end;|32: Result := '0.' + Result;|9: end|12: else|34: if N < Length( Result ) then|11: begin|72: Result := Copy( Result, 1, N ) + '.' + CopyEnd( Result, N + 1 );|9: end|12: else|11: begin|37: while N > Length( Result ) do|13: begin|33: Result := Result + '0';|12: end;|13: Exit;|10: end;|0:|28: L := Length( Result );|20: while L > 1 do|11: begin|53: if not (Result[ L ] in ['0','.']) then break;|17: Dec( L );|44: if Result[ L + 1 ] = '.' then break;|10: end;|67: if L < Length( Result ) then Delete( Result, L + 1, MaxInt );|0:|8: end;|0:|3:var|13: S: Boolean;|16:var F: Extended;|15: N: Integer;|32: Buf1: array[ 0..9 ] of Byte;|17: I10: Integer;|5:begin|16: Result := '0';|21: if E = 0 then Exit;|13: S := E < 0;|20: if S then E := -E;|0:|10: N := 15;|12: F := 5E12;|12: I10 := 10;|16: while E < F do|7: begin|13: Dec( N );|17: E := E * I10;|6: end;|16: if N = 15 then|20: while E >= 1E13 do|7: begin|13: Inc( N );|17: E := E / I10;|6: end;|0:|15: while TRUE do|7: begin|7: asm|16: FLD [E]|19: FBSTP [Buf1]|8: end;|33: if Buf1[ 7 ] <> 0 then break;|17: E := E * I10;|13: Dec( N );|6: end;|0:|37: Result := UnpackFromBuf( Buf1, N );|0:|35: if S then Result := '-' + Result;|4:end;|0:|42:function Single2Str( Sn: Single ): String;|5:begin|32: Result := Extended2Str4( Sn );|5:end; |1: |0:|0:|3: |29:Procedure THiAsmClass.doWork;|18: var text: String;|13: Sn : Single;|8: R:Real;|5:begin|30:text := ToStringEvent(Param1);|23:Sn:=Str2Single( text );|11://Sn:=1.05;|23:text := Single2Str(Sn);|30: _hi_OnEvent(onTrue,text) ;|4:end;|0:|0:|4:end.|
link(onTrue,11707526:doAdd,[(440,174)(440,181)])
link(Param1,2611930:Text,[])
}
Add(Button,575765,294,182)
{
Left=25
Top=470
link(onClick,7295647:doEvent1,[])
}
Add(Memo,11707526,469,175)
{
Left=5
Top=10
Width=270
Height=140
}
Add(Edit,2611930,378,63)
{
Left=10
Top=170
Width=105
Text="0.075"
}
Add(Hub,7295647,343,182)
{
link(onEvent1,11707526:doClear,[])
link(onEvent2,9268460:doWork,[(367,195)(367,174)])
}

карма: 6

0
Редактировалось 2 раз(а), последний 2022-06-30 11:56:24