-- ----------------------------------------------------------------------- -- Title: single_primitive_functions -- Last Mod: Fri Mar 29 14:20:14 1991 -- Author: Vincent Broman -- Copyright 1990 Vincent Broman -- Permission granted to copy, modify, or compile this software for -- one's own use, provided that this copyright notice is preserved intact. -- Permission granted to distribute compiled binary copies of this -- software which are linked in with some other application. -- Permission granted to distribute other copies of this software, -- provided that (1) any copy which is not source code, i.e. not in the -- form in which the software is usually maintained, must be accompanied -- by a copy of the source code from which it was compiled, and (2) the -- one distributing it must refrain from imposing on the recipient -- further restrictions on the distribution of this software. -- -- Visibility: -- Description: -- functions on floating point types whose implementation -- depends on access to the mantissa/exponent representation -- of the floating point number. this includes -- integer/fraction operations. -- -- This is the single precision nongeneric version. -- -- Exceptions: numeric_error upon overflow. -- ----------------------------------------------------------------------- with float_types; use float_types; package single_primitive_functions is -- function exponent( x: single) return integer; -- -- return the exponent k such that 1/2 <= x/(2**k) < 1, -- or zero for x = 0.0 . -- function mantissa (x: single) return single; -- -- return scale( x, - exponent( x)) if x is nonzero, 0.0 otherwise. -- function scale (x: single; k: integer) return single; -- -- return x * 2**k quickly, or quietly underflow to zero, -- or raise an exception on overflow. -- function leading_part (x: single; k: integer) return single; -- -- set all but the k most significant bits in the mantissa of x to zero, -- i.e. reduce the precision to k bits, truncating, not rounding. -- leading_part( x, k) = 0.0 if k < 1 and -- leading_part( x, k) = x if k >= single'machine_mantissa. -- function odd (x: single) return boolean; -- -- predicate indicates whether or not truncate( x) is an odd integer. -- function truncate (x: single) return single; -- -- truncate x to the nearest integer value with absolute value -- not exceeding abs( x). No conversion to an integer type -- is expected, so truncate cannot overflow for large arguments. -- function floor (x: single) return single; -- -- return as a single the greatest integer value <= x. -- function ceiling (x: single) return single; -- -- return as a single the least integer value >= x. -- function round (x: single) return single; -- -- return as a single the integer value nearest x. -- in case of a tie, prefer the even value. -- function "rem"( x, y: single) return single; -- -- returns the machine-representable value closest to -- x - y * round( x/ y), evaluated with exact arithmetic. -- The result is exact, except for y near zero, -- and only if the implementation does not handle denormalized numbers. -- numeric_error is raised if y = 0.0 . -- function adjacent( x: single; towards: single) return single; -- -- returns x if x = towards, otherwise returns the float_point number -- nearest to x in the direction toward towards. -- function successor( x: single) return single; -- -- return the next floating point number greater than x, -- or overflow if x = single'base'last. -- function predecessor( x: single) return single; -- -- return the next floating point number less than x, -- or overflow if x = single'base'first. -- function copy_sign( value: single; sign: single) return single; -- -- returns abs( value) with the sign of sign, i.e. -- when sign > 0.0 or sign = +0.0 returns abs( value), -- when sign < 0.0 or sign = -0.0 returns - abs( value). -- function multiply_sign( value: single; sign: single) return single; -- -- returns value multiplied by the sign of sign, i.e. -- when sign > 0.0 or sign = +0.0 returns value, -- when sign < 0.0 or sign = -0.0 returns - value. -- private pragma inline( copy_sign); pragma inline( multiply_sign); end single_primitive_functions; -- $Header: s_primitive_functions_s.a,v 3.23 91/03/29 15:32:33 broman Stab $