-- Copyright 1993-1998, by the Cecil Project -- Department of Computer Science and Engineering, University of Washington -- See the LICENSE file for license information. (--DOC Floats are floating-point numbers. Float-specific operations include various kinds of rounding and formatting a floating point number with a particular number of digits after the decimal point. Single floats and double floats are two representations of floats. --) -- methods for floats of different precisions -- (see single-float.cecil and double-float.cecil for two representations) abstract object float isa num; -- code to make different floating point precisions interact method =(l@:float,r@:float):bool { l.as_double_float = r.as_double_float } method <(l@:float,r@:float):bool { l.as_double_float < r.as_double_float } method +(l@:float,r@:float):float { l.as_double_float + r.as_double_float } method -(l@:float,r@:float):float { l.as_double_float - r.as_double_float } method *(l@:float,r@:float):float { l.as_double_float * r.as_double_float } method /(l@:float,r@:float):float { l.as_double_float / r.as_double_float } -- some simple methods for all precisions method as_float(f@:float):float { f } method hash(f@:float, range:int):int { -- boy, this is a horrible hash function hash(as_int(f*1000.0), range) } signature sin(float):float; signature cos(float):float; signature tan(float):float; signature asin(float):float; signature acos(float):float; signature atan(float):float; signature exp(float):float; signature log(float):float; signature sqrt(float):float; signature round_as_int(float):int; signature round(float):float; signature round_towards_zero(float):float; signature ceiling(float):float; signature floor(float):float; signature print_string(float, num_decimal_places:int):string; signature print_string_full(float):string;