J
jacob navia
Andy Champ a écrit :
Sure you do. At the start of the function the code will execute a load
from a 64 bit constant in the general case. If the compiler can prove
that a float (or even an integer) would do, maybe it does emit other
ionstructions. But in the *general* case you load a 64 bit constant from
memory with the FPU, then you store it in the address of the variable a.
Exactly. Here you say that I am right...
The FPU can load 80 or 64 or 32 bit floats with different
opcodes.
Yeah... The next generation will probably use something else.
Thank you for your contribution Andy.
jacob
I am familiar with neither of the two gentlemen. However, I must
disagree with you on that.
My understanding (and I'm prepared to be corrected on this) is that when
you write
double a = 12.345;
you are requesting the compiler to produce a value in the variable "a"
which is the double equivalent nearest to 12.345.
True
You are not forcing the compiler to do this; an optimiser may decide to
remove the statement completely.
Maybe
You are certainly not instructing it to initialise it by loading it from
a constant of that value.
Sure you do. At the start of the function the code will execute a load
from a 64 bit constant in the general case. If the compiler can prove
that a float (or even an integer) would do, maybe it does emit other
ionstructions. But in the *general* case you load a 64 bit constant from
memory with the FPU, then you store it in the address of the variable a.
Certain constant values are best produced in
different ways. In the Intel/Microsoft world (which is the one I'm most
familiar with) this statement would probably result in a load into an
FPU register from a single precision float in memory.
Exactly. Here you say that I am right...
It almost
certainly would not load a 64-bit memory location - which is what a
double is - with a value, because intermediate computations are carried
out in 80-bit registers.
The FPU can load 80 or 64 or 32 bit floats with different
opcodes.
Sadly I can offer no good texts for non-programmers in C++. If you want
some hints for Java I can get them - I barely know the language myself,
but my son has just finished his degree!
Andy
Yeah... The next generation will probably use something else.
Thank you for your contribution Andy.
jacob