Results 1 to 2 of 2
Thread: Character arithmetic issues
- 08-04-2010, 12:31 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 1
- Rep Power
- 0
- 08-04-2010, 12:52 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,380
- Blog Entries
- 7
- Rep Power
- 17
The compiler can only do 'constant folding' i.e. it can do calcualations on expressions that consists of constant operands only. Your first expression is such an expression and the compiler 'knows' that 'a'+1 == 'b' which fits in a character. The third expression isn't a constant expression so the compiler converts the single constant 'a' to an int, generates code for the addition operator and assumes that the result is also of type int. The result might not fit in a char so the compiler complains about it.
kind regards,
Jos
Similar Threads
-
Polynomials Arithmetic
By thisisIT in forum New To JavaReplies: 3Last Post: 03-09-2010, 01:27 PM -
Arithmetic Stacks
By unc123w in forum New To JavaReplies: 22Last Post: 10-21-2008, 08:24 PM -
reading text character by character
By bugger in forum New To JavaReplies: 2Last Post: 11-09-2007, 08:54 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks