How to get the fraction and exponent of a real number in Pascal

1 Answer

0 votes
program FrexpExample;

uses
  Math, SysUtils;

var
  d: Double;
  fraction: Extended;
  exponent: LongInt;

begin
  d := 3.14;
  
  Frexp(d, fraction, exponent);
  
  Writeln('fraction = ', FloatToStrF(fraction, ffFixed, 8, 6),
          ' exponent = ', exponent);
end.



(*
run:

fraction = 0.785000 exponent = 2

*)

 



answered Jun 30, 2025 by avibootz
...