Floating-point tolerance tests

Absolute tolerance:

  • Not good for big numbers
abs(x–y) <= tol1

Relative tolerance:

  • Not good for small numbers
abs(x–y) <= tol2 * max(abs(x), abs(y))

Combined tolerance test:

(abs(x-y) <= tol1) ||
  (abs(x-y) <= tol2 * max(abs(x), abs(y))

equal to:

abs(x-y) <= tol1 * Max(1.0f, tol2/tol1 * max(abs(x), abs(y))

which for tol1=tol2 becomes:

abs(x-y) <= tol1 * Max(1.0f, abs(x), abs(y))

 

References:

  • Real time collision detection, Christer Ericson

 

Daily Calorie Requirements for Cats

 

body weight
in pounds
growing
kitten
normal,
neutered adult
intact
adult
obese
prone
weight
loss
4 275 132 154 110
5 325 156 182 130
6 373 179 209 149
7 418 200 234 167
8 460 221 258 184
9 503 241 281 201
10 545 262 305 218 174
11   281 328 234 187
12   300 350 250 200
13   318 371 265 212
14   336 392 280 224
15   354 413 295 236
16   372 434 310 248
17   389 454 324 259
18   407 475 339 271
19   424 494 353 282
20   439 512 366 293

PDF link: CalorieRequirementsForCats