gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Puzzling unsigned integer value problems.

#123007 - Dark Knight ez - Sat Mar 24, 2007 1:30 pm

Hey all.

I've stumbled upon a problem.


Small background
============
I've written a model converter (.x format) to NDS display list format.
I read in the model... put it converted in a u32 array, and then print out the array to a file looking like this:

Code:
u32 modelDisplayList[] = { 3859,  572727872,  0,  74253290,  11468960, ... };


I print such a u32 value first to a temporarily buffer with sprintf("%u", displayList[..]); and then print that buffer out to the file.


Actual problem
===========
Anyway, now for the problem...
when I include this in my code and try to compile it, I get a couple of the following warnings:
"warning: this decimal constant is unsigned only in ISO C90".
I looked that message up, but can't quite grasp why it would say that... as the following values for which it said that are perfectly within range of a u32 (2^32-1, right?):

4294312053
4294049909
4294180864
4294181065
4294312161
4294312161
4294377355
4294377247
4294311936
4294049792
4294246199

I mean... 2^32-1 == 4294967295, which is a lot higher than these values.
Plus, I printed these values out, out of an (on the NDS) existing array of u32s.
Anyone know a way to solve this problem?
_________________
AmplituDS website

#123008 - Lick - Sat Mar 24, 2007 1:37 pm

You can get rid of that warning if you put "UL" after those values.

400000000UL, ... etc
_________________
http://licklick.wordpress.com

#123009 - Dark Knight ez - Sat Mar 24, 2007 1:45 pm

Thanks, Lick. Worked like a charm.
_________________
AmplituDS website

#123024 - 3D_geek - Sat Mar 24, 2007 6:13 pm

Lick wrote:
You can get rid of that warning if you put "UL" after those values.

400000000UL, ... etc


Actually - not 'UL' - that makes an unsigned LONG - you want just 'u' - for 'unsigned int'. UL will work - but it's not **RIGHT**.

#123036 - Dark Knight ez - Sat Mar 24, 2007 7:53 pm

Thank you. Even better then. :)
_________________
AmplituDS website

#123049 - Lick - Sat Mar 24, 2007 9:21 pm

Aren't they both 32bit?
_________________
http://licklick.wordpress.com