MOO-cows Mailing List Archive

[Prev][Next][Index][Thread]

floating point support (was Re: suspend())



Pavel writes:
> (I just have to finish integrating HPA's floating-point support,
> a task which is going well and is more than half done.)

[...since I don't know exactly what's in HPA's floating-point support,
 I'll just insert a random plea and/or hope that HPA did it right...]

Whatever you do, please do *NOT* put in implicit coercions.  
For example, in

  a = 5.0;
  b = 3;
  c = a / b;

the third line should be throwing an error.  It may seem convenient to have
an implicit coercion in there, but in the long run this will lead to 
error-prone
code with truncations silently occurring where you least expect them.

People seem to have this idea that, because integers can be viewed as a 
subSET
of the reals, that integers, as a datatype, should be a subTYPE of the 
real/float
datatype, and it just ain't so... (capsule summary:  it's not the sets of 
elements
that matters so much as the sets of OPERATIONS that you want to be able to 
use; 
sin is not a sensible operation to use on integers ($trig_utils 
notwithstanding),
nor is % a sensible operation to use on floats; end of story).





Follow-Ups:

Home | Subject Index | Thread Index