mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 06:09:11 +02:00
* fix wrong sign change handling
+ add 'H' to view current value as hexadecimal
This commit is contained in:
parent
fe82c8b418
commit
6769598ff4
@ -50,6 +50,7 @@ type
|
|||||||
Operand: extended;
|
Operand: extended;
|
||||||
Memory: extended;
|
Memory: extended;
|
||||||
DispNumber: extended;
|
DispNumber: extended;
|
||||||
|
HexShown : boolean;
|
||||||
constructor Init(var Bounds: TRect);
|
constructor Init(var Bounds: TRect);
|
||||||
constructor Load(var S: TStream);
|
constructor Load(var S: TStream);
|
||||||
function CalcKey(Key: string): boolean;
|
function CalcKey(Key: string): boolean;
|
||||||
@ -162,6 +163,7 @@ begin
|
|||||||
EventMask := evKeyDown + evBroadcast;
|
EventMask := evKeyDown + evBroadcast;
|
||||||
Clear;
|
Clear;
|
||||||
HelpCtx:={hcCalculatorLine}0;
|
HelpCtx:={hcCalculatorLine}0;
|
||||||
|
HexShown:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TCalcDisplay.Load(var S: TStream);
|
constructor TCalcDisplay.Load(var S: TStream);
|
||||||
@ -169,6 +171,7 @@ begin
|
|||||||
inherited Load(S);
|
inherited Load(S);
|
||||||
S.Read(Status, SizeOf(Status) + SizeOf(Number) + SizeOf(Sign) +
|
S.Read(Status, SizeOf(Status) + SizeOf(Number) + SizeOf(Sign) +
|
||||||
SizeOf(_Operator) + SizeOf(Operand));
|
SizeOf(_Operator) + SizeOf(Operand));
|
||||||
|
HexShown:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCalcDisplay.GetDisplay(var R: extended);
|
procedure TCalcDisplay.GetDisplay(var R: extended);
|
||||||
@ -239,7 +242,8 @@ begin
|
|||||||
fldcw fpucw
|
fldcw fpucw
|
||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
ErrorBox('Error while computing math expression',nil);
|
{ ErrorBox('Error while computing math expression',nil);
|
||||||
|
was only there for debugging PM }
|
||||||
{$ifdef go32v2}
|
{$ifdef go32v2}
|
||||||
Dpmi_LongJmp(CalcSigJmp,1);
|
Dpmi_LongJmp(CalcSigJmp,1);
|
||||||
{$else : not go32v2}
|
{$else : not go32v2}
|
||||||
@ -255,6 +259,7 @@ end;
|
|||||||
function TCalcDisplay.CalcKey(Key: string): boolean;
|
function TCalcDisplay.CalcKey(Key: string): boolean;
|
||||||
var
|
var
|
||||||
R,D: extended;
|
R,D: extended;
|
||||||
|
X : cardinal;
|
||||||
procedure CheckFirst;
|
procedure CheckFirst;
|
||||||
begin
|
begin
|
||||||
if Status = csFirst then
|
if Status = csFirst then
|
||||||
@ -287,6 +292,14 @@ begin
|
|||||||
StoreSigFPE:=Signal(SIGFPE,@CalcSigFPE);
|
StoreSigFPE:=Signal(SIGFPE,@CalcSigFPE);
|
||||||
{$endif HasSignal}
|
{$endif HasSignal}
|
||||||
if (Status = csError) and (Key <> 'C') then Key := ' ';
|
if (Status = csError) and (Key <> 'C') then Key := ' ';
|
||||||
|
if HexShown then
|
||||||
|
begin
|
||||||
|
GetDisplay(R);
|
||||||
|
SetDisplay(R,false);
|
||||||
|
HexShown := false;
|
||||||
|
if Key = 'H' then
|
||||||
|
Key := ' ';
|
||||||
|
end;
|
||||||
if Key='X^Y' then Key:='^';
|
if Key='X^Y' then Key:='^';
|
||||||
if length(Key)>1 then
|
if length(Key)>1 then
|
||||||
begin
|
begin
|
||||||
@ -326,8 +339,19 @@ begin
|
|||||||
if Length(Number) = 1 then Number := '0' else Dec(Number[0]);
|
if Length(Number) = 1 then Number := '0' else Dec(Number[0]);
|
||||||
SetDisplay(StrToExtended(Number),true); { !!! }
|
SetDisplay(StrToExtended(Number),true); { !!! }
|
||||||
end;
|
end;
|
||||||
|
'H':
|
||||||
|
begin
|
||||||
|
GetDisplay(R);
|
||||||
|
X:=trunc(abs(R));
|
||||||
|
Number:=HexStr(X,8);
|
||||||
|
HexShown:=true;
|
||||||
|
end;
|
||||||
'_', #241:
|
'_', #241:
|
||||||
if Sign = ' ' then Sign := '-' else Sign := ' ';
|
begin
|
||||||
|
if Sign = ' ' then Sign := '-' else Sign := ' ';
|
||||||
|
GetDisplay(R);
|
||||||
|
SetDisplay(-R,true);
|
||||||
|
end;
|
||||||
'+', '-', '*', '/', '=', '%', #13, '^':
|
'+', '-', '*', '/', '=', '%', #13, '^':
|
||||||
begin
|
begin
|
||||||
if Status = csValid then
|
if Status = csValid then
|
||||||
@ -547,7 +571,11 @@ end;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.4 2002-01-22 13:56:04 pierre
|
Revision 1.5 2002-01-22 14:56:37 pierre
|
||||||
|
* fix wrong sign change handling
|
||||||
|
+ add 'H' to view current value as hexadecimal
|
||||||
|
|
||||||
|
Revision 1.4 2002/01/22 13:56:04 pierre
|
||||||
* fix multiple FPU excpetion trapping problem for unix
|
* fix multiple FPU excpetion trapping problem for unix
|
||||||
|
|
||||||
Revision 1.3 2001/11/14 23:55:38 pierre
|
Revision 1.3 2001/11/14 23:55:38 pierre
|
||||||
|
Loading…
Reference in New Issue
Block a user