/* * call-seq: * flt.hash => integer * * Returns a hash code for this float. */ static VALUE flo_hash(num) VALUE num; { double d; char *c; int i, hash; d = RFLOAT(num)->value; if (d == 0) d = fabs(d); c = (char*)&d; for (hash=0, i=0; i<sizeof(double);i++) { hash = (hash * 971) ^ (unsigned char)c[i]; } if (hash < 0) hash = -hash; return INT2FIX(hash); }