Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

#26 2009-08-14 20:59:01

phrontister
Real Member

Offline

Re: Sum of fractions which equals 1

bobbym wrote:

Its ctrl + pause/break : this key is above the arrow keys (at the top).

Ah - found it! I'd never used that key before and must have skimmed over it when looking for it. sad

It stops program execution, as you said.

Thanks!


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
 

#27 2009-08-15 11:29:46

bobbym
Administrator

Online

Re: Sum of fractions which equals 1

Hi phrontister;

I tried that, but I got the same incorrect responses as before. Maybe I didn't code it correctly. I'll try again...

Code:

for n=10 to 0 step -1/5
   print n
next  n

Notice how instead of getting 0 he gets 0.20539126e-14, but at least the for next loop terminates.

Last edited by bobbym (2009-08-15 11:30:06)


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#28 2009-08-15 11:37:00

phrontister
Real Member

Offline

Re: Sum of fractions which equals 1

Hi Bobby,

bobbym wrote:

Notice how instead of getting 0 he gets 0.20539126e-14, but at least the for next loop terminates.

Yes - I'll have to remember that for situations where that is important (or maybe I should make it a habit anyway).

Some day this quirk won't exist and we won't have to dream up workarounds...and we'll laugh at the clunky ways of the old days.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
 

#29 2009-08-15 11:49:16

bobbym
Administrator

Online

Re: Sum of fractions which equals 1

Hi phrontister;

This problem will always exist with floating point arithmetic, you can delay it with more digits of precision, but when used incorrectly it will bite you.

Exact integer and rational arithmetic do not have this problem but it is not always possible to use them.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

Board footer

Powered by FluxBB