Boost logo

Boost :

Subject: Re: [boost] Proposed templated integer_sort
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-12-17 06:03:20


On Tue, Dec 16, 2008 at 10:17 PM, David Abrahams <dave_at_[hidden]> wrote:
>
> on Tue Dec 16 2008, "Giovanni Piero Deretta" <gpderetta-AT-gmail.com> wrote:
>
>> On Tue, Dec 16, 2008 at 3:03 PM, Pyry Jahkola <pyry.jahkola_at_[hidden]> wrote:
>>> Gevorg Voskanyan wrote:
>>>>
>>>> I suggest modifying CastFloatIter() function to use memcpy for accessing
>>>> floats as integers, as shown below:
>>>
>>> Hmm, I don't think it's any better than reinterpret casting.
>>
>> Yes it is. It has the nice property of not leading to UB.
>
> If so, that surprises me. Is it really guaranteed that all valid
> floating-point bit patterns are also valid integer bit patterns?
>

Well, in general I do not think so. I should have said that the result
is implementation defined. But it is defined on most common
architectures and their compilers.

-- 
gpd

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk