package FHEF is new Ada.Numerics.Generic_Elementary_Functions(FH_Float);
use FHEF;
+ ExpDecimals: constant FH_Float := 10.0 ** Decimals;
+ PNum: FH_Float;
Expanded: FH_Float;
Integer_Part_F: FH_Float;
Log_Arg_Floored: FH_Float;
- ExpDecimals: constant FH_Float := 10.0 ** Decimals;
+ Negative: Boolean;
begin
if Num = 0.0 then
Integer_Part := 0;
return;
end if;
- Log_Arg_Floored := FH_Float'Floor(Log(Base => 10.0, X => Num));
+ if Num < 0.0 then
+ Negative := True;
+ PNum := Num * (-1.0);
+ else
+ PNum := Num;
+ Negative := False;
+ end if;
+
+ Log_Arg_Floored := FH_Float'Floor(Log(Base => 10.0, X => PNum));
Expanded := 10.0 ** Log_Arg_Floored;
- Integer_Part_F := FH_Float'Floor(Num / Expanded);
- Decimal_Part := ((Num - (Integer_Part_F * Expanded)) / Expanded) * ExpDecimals;
+ Integer_Part_F := FH_Float'Floor(PNum / Expanded);
+ Decimal_Part := ((PNum - (Integer_Part_F * Expanded)) / Expanded) * ExpDecimals;
Exponent_Part := Integer(Log_Arg_Floored);
Integer_Part := Integer(Integer_Part_F);
+ if Negative then
+ Integer_Part := Integer_Part * (-1);
+ end if;
--Ada.Text_IO.Put_Line(FH_Float'Image(Num) & " --- " & Integer'Image(Integer_Part) & "," & FH_Float'Image(Decimal_Part) & "e" & Integer'Image(Exponent_Part));
end Split_Integer_Decimal_Exponent_Nums;