This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is 'unsigned' a datatype by itself?

Hi,
I have seen that some of the example programs availbale in this site define/declare variables as unsigned.

For eg: unsigned voltage; //A-to-D example program

What type would voltage in the above case assume? If it just holds a numeric value between 0 and 255 can I directly say
float f = voltage/4.5;
or do I need to do any casting on this statement.
Thanks in advance

Parents
  • Davis,
    Thank you so much for your response. Now I understand why it was working fine when it was assigned a numeric value.
    Is there a way to convert the result of a division operation on unsigned int variable to float. I tried doing this:
    unsigned step;
    float f = (float)(step/4.5);
    This shows *** FATAL ERROR L210: I/O ERROR ON INPUT FILE:
    EXCEPTION 0021H: PATH OR FILE NOT FOUND
    FILE: C:\KEIL\C51\LIB\C51FPS.LIB
    I have looked in the Keil installation folder for this file. I did see C51BFPS LIB file but not C51FPS file. Any idea what this file is and why is this necessary for the above code snippet.
    Thank you

Reply
  • Davis,
    Thank you so much for your response. Now I understand why it was working fine when it was assigned a numeric value.
    Is there a way to convert the result of a division operation on unsigned int variable to float. I tried doing this:
    unsigned step;
    float f = (float)(step/4.5);
    This shows *** FATAL ERROR L210: I/O ERROR ON INPUT FILE:
    EXCEPTION 0021H: PATH OR FILE NOT FOUND
    FILE: C:\KEIL\C51\LIB\C51FPS.LIB
    I have looked in the Keil installation folder for this file. I did see C51BFPS LIB file but not C51FPS file. Any idea what this file is and why is this necessary for the above code snippet.
    Thank you

Children