Connect with us

float and int

Discussion in 'Microcontrollers, Programming and IoT' started by juantravel, Oct 24, 2010.

Scroll to continue with content
  1. juantravel

    juantravel

    41
    0
    May 14, 2010
    I recently switched to using C to program pic's. I read that I can use int data types. How does my 8 bit handle those? What im trying to ask if it is possible what would be the equivalent to assembly in order to handle 2 byte data types
     
  2. LTX71CM

    LTX71CM

    182
    0
    May 23, 2010
    I know what you're asking but can't think of a helpful answer. Maybe you can provide a scenario where you think you would need an int and then a C example can be given.
     
  3. juantravel

    juantravel

    41
    0
    May 14, 2010
    Well I was reading the manual.pdf for pic 10/12/16. It gives me supported data types for the compiler (Section 3.3). Pic 10/12/16 are all 8 bit micro's. How does a 8 bit micro handle a int type(2 bytes). Also I have read that 8 bit micros cant handle float point type either..but the compiler does.. sorry for the confusion. Good example if i wanted to do math with a larger number then 255.
     
    Last edited: Oct 24, 2010
  4. LTX71CM

    LTX71CM

    182
    0
    May 23, 2010
    It handles an int a byte at a time. Some 8 bit mcus can handle floats but it eats a lot of code space and is most often ill-advised.

    Doing the math is easy provided you have the space. In C it's as simple as:

    Code:
    void main(void){
        unsigned int var = 0;
                var = 500 + 277;
    }
    
    Just perform the math as you would write it, though always be mindful of how big you expect or need a number to be and choose the appropriate data type.
     
  5. juantravel

    juantravel

    41
    0
    May 14, 2010
    Thank you :)
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-