math.inc 886 B

123456789101112131415161718192021222324252627282930313233
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2006 by the Free Pascal development team.
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {$ifdef FPC_INCLUDE_SOFTWARE_LONGWORD_TO_DOUBLE}
  11. function fpc_longword_to_double(i: longword): double; compilerproc;
  12. var
  13. l : longint;
  14. begin
  15. {$ifopt R+}
  16. {$define HAS_OPTR}
  17. {$endif}
  18. {$r-}
  19. l:=longint(i);
  20. {$ifdef HAS_OPTR}
  21. {$r+}
  22. {$endif}
  23. if l>=0 then
  24. fpc_longword_to_double:=double(l)
  25. else
  26. fpc_longword_to_double:=-double(abs(l));
  27. end;
  28. {$endif FPC_INCLUDE_SOFTWARE_LONGWORD_TO_DOUBLE}