[SJF Logo]
Steve Friedl's Weblog

May 05, 2003
New toy: C data type promotions calculator

I'm writing an article on dealing with C compiler warnings, and some of them that deal with signed/unsigned conflicts are pretty hard to follow and understand. When dealing with any binary operator, the compiler normalizes the types of both operands until they are the same. These are called "The Usual Conversions".

The rules vary depending on whether this is an ISO/ANSI compiler or a "traditional" one, and sometimes on the sizes of the integral data types, and it's hard to keep them straight without being an expert.

Being an expert :-), I wrote a small web-based calculator that takes the two data types and some of the compiler parameters, and it shows the results of the unary conversions applied to each operand independently, then the binary conversion that normalizes the two. The final type is always the same.

Unixwiz.net "Usual C Conversions" calculator

Posted by Steve at May 05, 2003 09:26 PM | TrackBack
Comments
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?