News for hackers. Stuff that matters.
Re:How many floating-point numbers are in the interval [0,1]... by fm77 on Saturday April 15, 2023 @03:34PM (#35583855)
In Turbo Pascal :-) you have to filter for NaN or else you gonna get a Runtime Error.

  const NaN=$7F80;

  var x, total: Longint;
      f: single absolute x;
      r: record Lo,Hi:Word; end absolute x;

  begin 
    total:=0;
    x:=0;
    repeat
      inc(total, ord((r.Hi and NaN <> NaN) and (0<=f) and (f<=1)));
      inc(x);
    until x=0;
    WriteLn('total: ', total);
  end.
total: 1065353218 (in ca. 40 seconds)

There are no comments on this comment yet.