int float may be rounded overow not possible int

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: bit) double precision (64-­‐bit) Default rounding mode is round-­‐to-­‐even #include <math.h> to get INFINITY and NAN constants Equality (==) comparisons between floa-ng point numbers are tricky, and oBen return unexpected results §  Just avoid them! §  Subs=tute things like: (abs(x-­‐y) / max(abs(x),abs(y))) < epsilon §  §  Not guaranteed – depends on what you’re doing, the data, etc. When in doubt, find a trained Numerical Analyst or use a carefully-­‐ wri[en library Floa-ng Point in C University of Washington Floa-ng Point in C ¢  Conversions between data types: §  Cas=ng between int, float, and double changes the bit representa=on!! §  int → float §  May be rounded; overflow not possible §  int → double or float → double §  Exact conversion, as long as int has ≤ 53-­‐bit word size §  double or float → int §  Truncates frac=onal part (rounded toward zero) §  Not defined when out of range or NaN: generally sets to Tmin Floa-ng Point in C University of Washington Summary ¢  Zero 0 00000000 0000000000000000000000 ¢  Normalized values s ¢  1 to 2k-...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online