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

Discussion in '3DS - Homebrew Development and Emulators' started by kprovost7314, Sep 15, 2016.

  1. kprovost7314
    OP

    kprovost7314 GBAtemp's Official Bara Master

    Member
    1,658
    841
    Dec 24, 2014
    United States
    In that bara manga ( ͡° ͜ʖ ͡°)
    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?
     
  2. evandixon

    evandixon PMD Researcher

    Member
    1,652
    775
    May 29, 2009
    United States
    u8 - unsigned 8 bit integer
    u32 - unsigned 32 bit integer
    i8 - signed 8 bit integer
    i32 - signed 32 bit integer
     
  3. kprovost7314
    OP

    kprovost7314 GBAtemp's Official Bara Master

    Member
    1,658
    841
    Dec 24, 2014
    United States
    In that bara manga ( ͡° ͜ʖ ͡°)
    It clearly says that, but it doesn't say the type of value it uses.
     
  4. ketal

    ketal aiueo

    Member
    744
    569
    Aug 20, 2015
    Italy
    u32 is not an hex value. It's a data type, an unsigned 32bit integer. u8 is an unsigned 8bit integer.
     
  5. nop90

    nop90 GBAtemp Maniac

    Member
    1,344
    2,027
    Jan 11, 2014
    Italy
    Rome
    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, Sep 15, 2016
    Minnow likes this.
  6. kprovost7314
    OP

    kprovost7314 GBAtemp's Official Bara Master

    Member
    1,658
    841
    Dec 24, 2014
    United States
    In that bara manga ( ͡° ͜ʖ ͡°)
    I don't think anyone understands my question...
     
  7. ItsMetaKnight

    ItsMetaKnight GBAtemp Advanced Fan

    Member
    772
    151
    Mar 4, 2008
    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.
     
  8. kprovost7314
    OP

    kprovost7314 GBAtemp's Official Bara Master

    Member
    1,658
    841
    Dec 24, 2014
    United States
    In that bara manga ( ͡° ͜ʖ ͡°)
    But how can you tell which one is it?
     
  9. ItsMetaKnight

    ItsMetaKnight GBAtemp Advanced Fan

    Member
    772
    151
    Mar 4, 2008
    Completely up to the developer.
    You need to understand the rest of the code in order to know what the variable is used for.
     
    Minnow likes this.
  10. nop90

    nop90 GBAtemp Maniac

    Member
    1,344
    2,027
    Jan 11, 2014
    Italy
    Rome
    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)
     
  11. EmuAGR

    EmuAGR GBAtemp Regular

    Member
    184
    115
    Jan 11, 2016
    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, Sep 15, 2016
  12. Urbanshadow

    Urbanshadow GBAtemp Maniac

    Member
    1,288
    468
    Oct 16, 2015
    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.
     
    EmuAGR likes this.