Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Ints and floats


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 meanwhile   Members   -  Reputation: 98

Like
-2Likes
Like

Posted 31 January 2012 - 01:30 PM

After reading that converting between ints and floats is a mortal sin,
I decided to rewrite my simple software rasterizer to use floats only.

No more 255, just plain 1.
No more i * a / 255, just plain f * a.
No more overflow checks, just treat 1.25 as white.

The result? It runs SLOWER now than before.
Maybe memory bandwidth is more of an issue.

Sponsor:

#2 Telastyn   Crossbones+   -  Reputation: 3730

Like
0Likes
Like

Posted 31 January 2012 - 03:20 PM

Conversion isn't a mortal sin for performance reasons (though it doesn't help); it's due to accuracy reasons.

#3 Cornstalks   Crossbones+   -  Reputation: 6991

Like
0Likes
Like

Posted 31 January 2012 - 03:24 PM

The result? It runs SLOWER now than before.
Maybe memory bandwidth is more of an issue.


Are you asking why, or are you just complaining about it?
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#4 Dunge   Members   -  Reputation: 405

Like
0Likes
Like

Posted 31 January 2012 - 03:29 PM

A CPU calculate integer faster.
A GPU calculate floats faster.

You use a SOFTWARE rasterizer, hence done on the CPU. Of course floats will be slower. Unless you use some GPGPU calculations...

#5 swiftcoder   Senior Moderators   -  Reputation: 10399

Like
1Likes
Like

Posted 31 January 2012 - 03:51 PM

A CPU calculate integer faster.

Once upon a time, yes - these days it's not quite so cut-and-dried. The FPU may actually be faster than the ALU at many tasks, especially if you can make use of SIMD (SSE/altivec) instructions.

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#6 mhagain   Crossbones+   -  Reputation: 8282

Like
3Likes
Like

Posted 31 January 2012 - 04:01 PM

As a rule of thumb, every time you see a statement to the effect that "X is a mortal sin", or "you should never do Y", or "if you're not doing Z you're doing it wrong", you should always look for the part of it beginning with the words "but..." or "except..."

If that's missing take it with an appropriately sized grain of salt.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS