Ennen:
The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.
-- FORTRAN manual for Xerox Computers
Nyt:
I was wondering if the Java compiler (I am using Sun's j2sdk 1.4.2_10) will change Math.PI * 2.0 into a constant in bytecode, or should I make a final double above my function call?
Should the value of PI change, then you will need to recompile your code.
Tom Hawtin
--
Unemployed English Java programmer
The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.
-- FORTRAN manual for Xerox Computers
Nyt:
I was wondering if the Java compiler (I am using Sun's j2sdk 1.4.2_10) will change Math.PI * 2.0 into a constant in bytecode, or should I make a final double above my function call?
Should the value of PI change, then you will need to recompile your code.
Tom Hawtin
--
Unemployed English Java programmer
Vastaukset 3
Vanhimmat
Jooh! Eikös PI arvo ole aina vakio, vain tarkkuus voi muuttua, riippuen systeemistä?
osuit oikeaan
Nuo molemmat absurdiudet näyttävät miten ihmiset ajattelevat. Kirjoittaja on liittänyt IT-mantran "jos vakion arvo muuttuu ..." miettimättä vakion luonnetta tällä kertaa.