Don't forget to cast (a.k.a. 1 / 5 = 0)

| No Comments
You would think that people would remember this. C keeps things as an integer unless you tell it otherwise. This means that unless you tell the computer otherwise, it will keep blithely working on integers. so to get a proper answer cast one of the values to a float, and the entire operation gets done as a floating point operation.
Simple rules for simple languages.

Leave a comment

About this Entry

This page contains a single entry by Pete Shanahan published on October 12, 2005 9:05 PM.

Patch Wednesday was the previous entry in this blog.

Video iPod - meh. is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.