Computational Physics Laboratory PHZ4151C/PHZ5156C
  Spring 2009

  Class Meetings: HCB 0219, Tuesday and Thursday from 2:00 to 3:15 PM

  Office Hours: Wednesday 4:00 - 5:00 or upon appointment

  Course Text: David Yevick, A First Course in Computational Physics and Object-Oriented Programming with C++

Numerical Limits in Programming


Part 1a   Write a program to find the largest integer N (computationally) such that (N+1) equals the integer which is larger than N by one.

Answer: 2147483646

Source Code


Part 1b   Write a program to find the largest positive floating-point number x, to within a factor of 2, such that:
(1.0 + x) - 1.0 == 0.

Answer: 5.42101e-20 (on comphy)

Source Code