signed to unsigned conversion

Discussion in 'General Electronics Chat' started by aamirali, Nov 6, 2012.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    415
    1
    1. I have a signed int no with range -3000 to +3000. No I have to convert it to unsigned. so I have done:


    uint16_t x = (uint16_t)(temp + 4096);

    where temp is signed var with range -3000 to +3000. is it right method.
     
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,884
    1,005

    Look at the abs function. Look down the list of forums a bit.

    You know there is a specific forum for programming? This forum is General Electronics Chat.
     
Loading...