Re: Larkin, Power BASIC cannot be THAT good:



On Thu, 11 Jun 2009 11:18:43 -0700 (PDT), Michael <mrdarrett@xxxxxxxxx> wrote:
On Jun 11, 10:48?am, Rich Grise <richgr...@xxxxxxxxxxx> wrote:
On Thu, 11 Jun 2009 08:56:10 -0700, Michael wrote:
On Jun 10, 8:07?pm, AZ Nomad <aznoma...@xxxxxxxxxxxxxxxxxxx> wrote:

I also never use constants like 25480. ?24*60*60 is far more readable
and less prone to error. ?It doesn't take a pico second more to
execute as the calculation is done at compile time, not run time.
Even with an interpreted language, it is only parsed once; ?if the
language system isn't shit, the calculated value will be saved in the
saved tokenized code.

Funny. ?I would use the 25480, and put the 24*60*60 in a comment.

Then again, I don't need to write high-performance code.

I hope not! I define the constant, then use the label. That way,
if it changes, you don't have to track down every instance to
change the hard numbers.

Cheers!
Rich


Like in a #define?

Funny thing is, 24x60x60 = 86,400, actually...

Not likely that 60 seconds in a minute, or 60 minutes in an hour,
would change... unless... the client moves from a 24-hour-workday to,
say, an 8-hour work day?

No, the point is to remove an opportunity for programmer error.
Let the compiler do the math.
.



Relevant Pages

  • Re: Larkin, Power BASIC cannot be THAT good:
    ... execute as the calculation is done at compile time, ... Even with an interpreted language, it is only parsed once;  if the ... saved tokenized code. ...
    (sci.electronics.design)
  • Re: Larkin, Power BASIC cannot be THAT good:
    ... execute as the calculation is done at compile time, ... Even with an interpreted language, it is only parsed once;  if the ... saved tokenized code. ...
    (sci.electronics.design)
  • Re: Larkin, Power BASIC cannot be THAT good:
    ... Writing readable programs is probably more important than anything else. ... execute as the calculation is done at compile time, ... Even with an interpreted language, it is only parsed once; ... saved tokenized code. ...
    (sci.electronics.design)
  • Re: Larkin, Power BASIC cannot be THAT good:
    ... I have done plenty of user RPL programming of HP calculators. ... execute as the calculation is done at compile time, ... Even with an interpreted language, it is only parsed once;  if the ... saved tokenized code. ...
    (sci.electronics.design)
  • Re: Constant evaluation
    ... return mass * g * height; ... My question is the mass*g part will be calculate at compile time or ... And if I use const double mass=2.4 instead, ... calculation of mass*g at compile time regardless of whether you use a ...
    (microsoft.public.vc.language)