Author Topic: Really a difference with float, int, double  (Read 239 times)

0 Members and 1 Guest are viewing this topic.

quaziconscience

  • Swamp Rat
  • Posts: 776
  • .net stuff
Really a difference with float, int, double
« on: July 12, 2019, 11:23:31 PM »
Is there much of a difference in speed for most applications between using float, int, double, etc anymore with the power of computers?  I imagine to notice it someone would have to develop some incredible program.  Am I wrong?

Atook

  • Swamp Rat
  • Posts: 933
Re: Really a difference with float, int, double
« Reply #1 on: July 13, 2019, 12:58:41 AM »
I'm curious about performance too.

But really, from an interfacing with CAD perspective, it's best just to feed CAD the type it's expecting.

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1363
  • class keyThumper<T>:ILazy<T>
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1363
  • class keyThumper<T>:ILazy<T>
Re: Really a difference with float, int, double
« Reply #3 on: July 13, 2019, 02:00:37 AM »
... and this will probably be enough to give you bloodshot eyes.

http://nicolas.limare.net/pro/notes/2014/12/12_arit_speed/

called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

dgorsman

  • Water Moccasin
  • Posts: 2392
Re: Really a difference with float, int, double
« Reply #4 on: July 15, 2019, 04:20:23 AM »
What scale are you looking at?  Hundreds to thousands, probably no difference visible to the user.  Hundreds of thousands to millions,  larger value types will start to show a difference.  Still, bad idea to get too complacent.  No need to be uber optimized everywhere, but being aware makes for better, more efficient code overall.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

MickD

  • Gator
  • Posts: 3289
  • (x-in)->[process]->(y-out)
Re: Really a difference with float, int, double
« Reply #5 on: July 15, 2019, 06:55:37 PM »

I don't know how much the C# compiler optimises memory for class variables but in C/C++ it can be important to 'byte align' your variables to make them easier to access in 32/64 bit lumps but that is probably less important than how you structure your routines and bulk data (cache misses can have a ~200X speed factor hit on cpu performance!). That is, it is more efficient to grab your functions and variables and hope they fit in the cache (say L1/L2) and then run them as much as you can before retrieving the next lot of code and data.
So yes, it _can_ be important if you are coding for embedded systems or VR/Games/Animation.

Given that, unless you are trying to perform gig's of calculations at 60 frames per second then it's not worth worrying about, even if it was slower using doubles over floats we're talking milliseconds 'difference' per run of routine. If this is really important then I wouldn't be using any language that's interpreted or that runs on a VM like C#.

hth
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6929
  • AKA Daniel
Re: Really a difference with float, int, double
« Reply #6 on: July 16, 2019, 06:32:48 AM »
Yes, they can make a huge difference if you're using SIMD, google SIMD-enabled types for .NET

SSE2 XMM registers:
    four 32-bit single-precision floating point numbers
    two 64-bit double-precision floating point numbers or
    two 64-bit integers or
    four 32-bit integers or
    eight 16-bit short integers or
    sixteen 8-bit bytes or characters.

Otherwise probably not, just use the type that you need