Re: [AD] float math function inconsistencies

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I checked quickly on Windows at lunch. In MSVC on x86 it seems to treat everything as doubles regardless of float or double. I think x86, even float is all double internally, of even higher precision if I remember correctly (96 bit?). I think it is only when it is stored that it is converted.

However, this is not true of all platforms, and usually the MS compilers are a little lax with the standards (usually in favour of the programmer, but never the less, not completely standard compliant). It is not always safe to assume what the compiler will do, and this kind of thinking doesn't make for highly portable code. You have plenty of elbow room for inefficiency on x86, but less so on mobile, especially where floating point and vector code is used. I'll try and have a look what clang spits out on iOS.

When I looked at the Allegro code quickly it looks like float literals are all postfix "f", but there are a lot of ints.


On 30 January 2013 12:27, Peter Wang <novalazy@xxxxxxxxxx> wrote:
On Wed, 30 Jan 2013 10:47:02 +0000, Nick Trout <chinbillybilbo@xxxxxxxxxx> wrote:
> Strictly speaking all floating point literals need an "f" on the end as
> well. I haven't checked but I believe all of these will generate a double,
> which then needs converting to float before they are used (every time they
> are used).

I think it'd have to be a pretty dumb or paranoid compiler to not
convert to a float literal at compile time.

Your patch looked okay.  I'd wanted to check it compiles with MSVC
but haven't got around to it.

Peter

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
--
https://lists.sourceforge.net/lists/listinfo/alleg-developers



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/