listings/chapter-1/reciprocal.cpp
raw| 1 | /*********************************************************************** |
| 2 | * Code listing from "Advanced Linux Programming," by CodeSourcery LLC * |
| 3 | * Copyright (C) 2001 by New Riders Publishing * |
| 4 | * See COPYRIGHT for license information. * |
| 5 | ***********************************************************************/ |
| 6 | |
| 7 | #include <cassert> |
| 8 | #include "reciprocal.hpp" |
| 9 | |
| 10 | double reciprocal (int i) { |
| 11 | // I should be non-zero. |
| 12 | assert (i != 0); |
| 13 | return 1.0/i; |
| 14 | } |
| 15 |