Unsigned arithmetic



I've been having discussion recently about the interpretation
to be given to conversion of a float value to unsigned integer.
The question involves treatment of negative values. My position
is that the conversion is mathematically meaningless, so it's
an exercise for the student as to which way is "best". A case
can possibly be made for either using or ignoring the sign of
the float value, but the choice is arbitrary.

An example of converting -23.1 to unsigned integer. To me, it
just doesn't seem that the result should be 23 (ignoring the
sign) as opposed to 0xFFFFFFE9 (negating the value and treating
the result as unsigned).
.



Relevant Pages

  • Re: pointer and array
    ... impossible to compare the values, ... int 3 and the float 3.14, that are equal when we convert them both ... the "double" 33554433.0 becomes 33554432.0 after conversion to ...
    (comp.lang.c)
  • RE: multiple repeatable "could not bulk copy out of table" errors
    ... in Query Analyzer or your favorite query execution tool. ... implicitly converted to float values thereby causing the conversion error. ... > new Agent action and object ID/Error from snapshot output: ...
    (microsoft.public.sqlserver.replication)
  • Re: IBM. PL/I and DPF
    ... "assigned" to an IEEE 754r decimal floating point receiving item, ... form of FLOAT, maybe FLOAT DEC, which is done using ... that when squared yields 2 ... no automatic conversion for generic functions. ...
    (comp.lang.pl1)
  • Re: Type casting
    ... I have a small mess with the conversion of numeric types in the ... the outcome of E / 2 cannot be of type float. ... trying to truncate a float to an integer, ... Float'Truncation truncates F to an integer, truncating toward zero, ...
    (comp.lang.ada)
  • Re: [Full-disclosure] Firefox 2.0.0.7 has a very serious calculation bug
    ... volatile double b = 0.1; ... There is no double to float conversion in the above code. ... errors are introduced and propagated through calculations. ...
    (Full-Disclosure)

Loading