Why do operations on single or int32 data types take longer time than on double data types on a 64 bit machine?

1 view (last 30 days)
On a 64 bit machine the following code takes more time to run when "a" and "b" are int32 or single(32 bits) than when they are double(64 bits):
a = 4096;
b = 128;
start = cputime;
for i=1:1048576
c = a/b;
end
t = cputime-start;
disp(t);
a = single(4096);
b = single(128);
start = cputime;
for i=1:1048576
c = a/b;
end
t = cputime-start;
disp(t);

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
It is possible for the 32-bit operations to run at the same speed or a bit slower than the 64-bit operations while working on a 64-bit machine. This is because of the architecture of the processors. One explanation could be that the registers in 64-bit machines are 64-bit wide and are faster in processing 64 bit operations than 32-bit operations.
On the other hand, if the machine is 32-bit the operations on single data types are faster than those on double data types.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!