Homebrew [Dev Question] Do types like u32, u8 mean something specific?

YugamiSekai

Well-Known Member
OP
Member
Joined
Dec 24, 2014
Messages
2,001
Trophies
1
Age
20
XP
2,105
Country
United States
I'm currently writing a new chapter in my dev guide about reading documentation (LEEKED) and I was just wondering if types meant something specific. Like if u8 are just integers in pointers or if u32 is just hex values. And if they're not set types, is there anyway to check and see if the type is an integer or something else?
 

ketal

aiueo
Member
Joined
Aug 20, 2015
Messages
744
Trophies
0
XP
657
Country
Italy
I'm currently writing a new chapter in my dev guide about reading documentation (LEEKED) and I was just wondering if types meant something specific. Like if u8 are just integers in pointers or if u32 is just hex values. And if they're not set types, is there anyway to check and see if the type is an integer or something else?
u32 is not an hex value. It's a data type, an unsigned 32bit integer. u8 is an unsigned 8bit integer.
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
2,984
Country
Italy
The number indicates the bits used to store a value in a variabile of that type. If you try to assign a value that needs more bits, some cast/truncation/overflow happens (depending the compiler and defined at compile time).

The u or the s mean unsigned and signed. With signed values the upper bit indicates a negative value and the ALU uses specific convention for handling such numbers. The unsigned values are simply positive base 2 numbers.

A thing to remember. Most compilers assumes char is u8, the 3ds toolchain uses it as a s8. Porting games to 3ds this caused me a lot of problems at debug time. But there is a compiler option to changes this if you need.

Sorry for the typos, I'm writing on a Mobile with italian language as default
 
Last edited by nop90,

ItsMetaKnight

Well-Known Member
Member
Joined
Mar 4, 2008
Messages
866
Trophies
0
Website
Visit site
XP
1,426
Country
Sorry, but your question doesn't make sense from the perspective of a developer.

If you need to store values larger than 255, u8 is not enough for you, so you go for u16.
If you need to store values larger than 65535, u16 is not enough for you, so you go for u32.
Any of these can be a pointer or a hex number or anything you want.
That's all.
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
2,984
Country
Italy
If you have to store the value of an ascii char u8 is enough.

If you have to store the x and y coordinate of a bitmap two u16 are fine, but most devs will use two u32 for simplicity.

If you have to address a nemory location on a 32bit system, u32 is the right choice.

If you have count time intervals in nanoseconds use u64

If you don't know the size of what you have ti store, before coding you have to learn to design (or hire a code designer)
 

EmuAGR

Well-Known Member
Member
Joined
Jan 11, 2016
Messages
205
Trophies
0
Age
30
XP
236
Country
Are you creating a dev guide when you don't know properly how to dev? Every variable just stores binary values. The representation depends on a "binary <-> whatever" function which draws on screen a symbolic representation of the binary value.

For example: A date might be a number of seconds from 1 Jan 1970. Then that number is represented as DD/MM/YY HH:mm:ss, or maybe YYYY/MM/DD hh:mm:ss. But the binary representation of the number is the same. We're who make sense of that number.
 
Last edited by EmuAGR,

Urbanshadow

Well-Known Member
Member
Joined
Oct 16, 2015
Messages
1,531
Trophies
0
Age
31
XP
1,422
Country
Even if they are used as generic data types, they are adaptations of unsigned int basic data type. Deep down in the compiler are treated as number literals during decoding. The purpose of the type is up to the developer though.
 
  • Like
Reactions: EmuAGR
General chit-chat
Help Users
  • No one is chatting at the moment.
    KenniesNewName @ KenniesNewName: Underwraps 2 is out checks all the Disney woke boxes