gnash-commit
[Top][All Lists]
Advanced

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

Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac...


From: Benjamin Wolsey
Subject: Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac...
Date: Fri, 13 Jun 2008 18:57:11 +0200

> >
> 
> what about 'double' to 'float' conversion? Is it also undefined?
> 

Float-to-float conversion:

An rvalue of floating point type can be converted to an rvalue of
another floating point type. If the source value can be exactly
represented in the destination type, the result of the conversion is
that exact representation. If the source value is between two adjacent
destination values, the result of the conversion is an
implementation-defined choice of either of those values. Otherwise, the
behavior is undefined.

So yes, if the double is outside the range of the float type.

> FloatToFixed16() and DoubleToFixed16() are only used for matrix at the
> moment, and they are mainly for converting cos() and sin() values to
> integers, so shouldn't be a problem(all in valid ranges). I may move
> them inside the matrix class later.
> 
That would surely be a part of a good answer, so that no one is tempted
to use them generally. Perhaps documenting the range of their allowed
usage would also be useful.

I see that the cos/sin values are multiplied by scale first before being
passed to FloatToFixed16. If the maximum allowable value for
FloatToFixed16 is 2**32 / 65535.0, it means the maximum scale is about
65537. It sounds like this would be an unusual value for scale - is that
correct?

> PIXEL_TO_TWIPS() then need to be inspected if it is really unsafe.

It also seems very unlikely that this will be a common problem. The
lowest pixel value that would cause a problem would be 107 million.

In both cases, how much of a performance hit would it be to test the
number for an overflow and reject it? Would that give correct behaviour?

The final question that occurs to me is whether a negative float is
'representable' in an unsigned value, or whether any negative value for
the float is undefined behaviour when casting to unsigned int.

-bwy.

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


reply via email to

[Prev in Thread] Current Thread [Next in Thread]