[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac...
From: |
zou lunkai |
Subject: |
Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac... |
Date: |
Fri, 13 Jun 2008 23:44:40 +0800 |
>
> > All of these rely on undefined behaviour. Conversion from float to an
> > integer is undefined behaviour if the float value cannot be represented
> > in the integral value after truncation (i.e. when the fractional value
> > has been removed).
> >
>
'undefined behaviour' only occurs when the 'double' number is out of
an integer's range in theory. In practice, they are all 'defined' to
MSVC6, GCC3.4 and GCC4.1. I planed to add some tests to
testsuite/server for these simple functions. It's easy to test if any
compiler gives unexpected results.
>
> Also you can't convert a double this way, as a double is 8 bytes, and on
> many systems an int is only 4 bytes still. The only way I know to really
> convert it is to separate the integer value and the fractional values and
> then round one way or the other.
>
I know that sizeof(double) == 8 and sizeof(int) == 4. But why it's
related? I do not expect an 'integer' to represent a 'double' without
loss. Instead, I do need the loss. I need the truncation.
--zou
On 6/13/08, Rob Savoye <address@hidden> wrote:
> Benjamin Wolsey wrote:
>
> > All of these rely on undefined behaviour. Conversion from float to an
> > integer is undefined behaviour if the float value cannot be represented
> > in the integral value after truncation (i.e. when the fractional value
> > has been removed).
> >
>
> Also you can't convert a double this way, as a double is 8 bytes, and on
> many systems an int is only 4 bytes still. The only way I know to really
> convert it is to separate the integer value and the fractional values and
> then round one way or the other.
>
> - rob -
>
>
>
> _______________________________________________
> Gnash-commit mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/gnash-commit
>
- [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac..., Zou Lunkai, 2008/06/13
- Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac..., Benjamin Wolsey, 2008/06/13
- Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac..., Rob Savoye, 2008/06/13
- Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac...,
zou lunkai <=
- Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac..., Benjamin Wolsey, 2008/06/13
- Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac..., zou lunkai, 2008/06/13
- Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac..., Benjamin Wolsey, 2008/06/13
- Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac..., zou lunkai, 2008/06/13
- Re: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac..., Benjamin Wolsey, 2008/06/15