Thread: I hate "C"
View Single Post
  #4   Spotlight this post!  
Unread 20-01-2007, 00:26
maniac_2040's Avatar
maniac_2040 maniac_2040 is offline
Registered User
AKA: Matt
FRC #3302 (Turbo Trojans)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Clawson, Michigan
Posts: 34
maniac_2040 is infamous around these partsmaniac_2040 is infamous around these partsmaniac_2040 is infamous around these partsmaniac_2040 is infamous around these parts
Send a message via MSN to maniac_2040
Re: I hate "C"

Quote:
Originally Posted by Jake M View Post
You know, I don't quite see why you converted everything to long. The two types are essentially the exact same: both are unsigned, 4 byte numerical variables. It is strange that you would have this problem by switching this yes, but I don't see why you would think it would change anything. In my experiences, I've never seen any difference at all between the two, except for the name. (I may be missing something, but if I am, then I'll learn something here too) If you were trying to make the variable larger, to prevent overflow, the only way you can go bigger is to use a long long or long long int.

Also, could you provide some sample values that those variables might have. If it is indeed a casting problem, and I have an idea of what those values should be, I can run some test code and probably figure it out.
they're not both 4 bytes. For some reason, an int is two bytes here. I found this out by printing a variable(int type) that was being incremented. When it was incremented pasted 32,xxx it overflowed and went back to -32,xxx. A long is bigger than an int. it wouldn't make much sense if it was the same size.

EDIT: Also, neither are unsigned, I have no idea where you got this from.