/src/lib/numeric/real_128.e

http://github.com/tybor/Liberty · Specman e · 82 lines · 45 code · 14 blank · 23 comment · 1 complexity · de5b9a4c30d7eef6b6b3c617ee311818 MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. expanded class REAL_128
  5. insert
  6. REAL_GENERAL
  7. feature {ANY} -- Conversions:
  8. force_to_real_32: REAL_32
  9. external "built_in"
  10. end
  11. force_to_real_64: REAL_64
  12. external "built_in"
  13. end
  14. force_to_integer_64: INTEGER_64
  15. external "built_in"
  16. end
  17. force_to_integer_32: INTEGER_32
  18. external "built_in"
  19. end
  20. force_to_integer_16: INTEGER_16
  21. external "built_in"
  22. end
  23. feature {ANY}
  24. zero: REAL_32 0.0
  25. one: REAL_32 1.0
  26. infix "~=" (other: like Current): BOOLEAN
  27. do
  28. Result := (Current - other).abs * ({REAL_128 2.0} ^ (mantissa_bits - precision)) <= Current.abs
  29. end
  30. hash_code: INTEGER
  31. do
  32. Result := force_to_integer_32
  33. if Result < 0 then
  34. Result := -(Result + 1)
  35. end
  36. end
  37. mantissa_bits: INTEGER_8 112
  38. exponent_bits: INTEGER_8 15
  39. feature {}
  40. sprintf (buffer: NATIVE_ARRAY[CHARACTER]; mode: CHARACTER; f: INTEGER; value: REAL_128)
  41. external "plug_in"
  42. alias "{
  43. location: "${sys}/runtime"
  44. module_name: "basic_sprintf"
  45. feature_name: "sprintf_real_extended"
  46. }"
  47. end
  48. end -- class REAL_128
  49. --
  50. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  51. --
  52. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  53. -- of this software and associated documentation files (the "Software"), to deal
  54. -- in the Software without restriction, including without limitation the rights
  55. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56. -- copies of the Software, and to permit persons to whom the Software is
  57. -- furnished to do so, subject to the following conditions:
  58. --
  59. -- The above copyright notice and this permission notice shall be included in
  60. -- all copies or substantial portions of the Software.
  61. --
  62. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  64. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  65. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  66. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  67. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  68. -- THE SOFTWARE.