1

So if I have lets say 4 integers:

int a = 50000 , int b = 5000000 , int c = 100 , int d = 500

Now what I wanted to run is b - a And c - d.

my question is would b-a run slightly slower than c - d or they would be executed in the exact same speed by the processor?

  • If that were your bottleneck concern, you must be be doing something pretty advanced. – Mitch Wheat Oct 15 '14 at 15:25
  • 2
    pretty much any modern cpu will do a simple add/sub instruction in a single clock cycle, IF the numbers can fit into single registers. – Marc B Oct 15 '14 at 15:25
  • it also depends on the programming language you choose and how many bits are allocated for an integer value, but it wouldn't make any big difference as far as the speed is concerned – Sufiyan Ghori Oct 15 '14 at 15:30
  • Elaborating on @MarcB's answer: if both `b - a` and `c - d` are acting on variables of the same *type* (i.e. `int`) then they will take the same amount of processor time. – Mr. Llama Oct 15 '14 at 15:35

1 Answers1

0

First of all, in the case you presented operations will be exactly the same. You can read about how these circuits do the work here

Second of all, fixed point mathematics are very very very fast on all computers these days. If this is your bottleneck, I don't know what to tell you.

ControlAltDel
  • 33,923
  • 10
  • 53
  • 80