Thread: casting 4 chars to long int

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2019
    Posts
    1,078
    But.. you don't need that union or to use a pointer to use the 12 bits ADC from PIC18x:
    Code:
      uint32_t value = (ADCRESH << 8) | ADCRESL;
      double flt = (double)value / ((1 << 12) - 1);
    Make sure ADCCON0.FM bit is set.
    (Assuming 'double' has 53 bits of precision here).
    Last edited by flp1969; 03-07-2022 at 04:54 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. casting clock_t to unsigned long
    By johnmerlino in forum C Programming
    Replies: 3
    Last Post: 04-19-2014, 11:28 AM
  2. 3 each 8bit chars from a 32bit long int
    By Brucewd in forum C Programming
    Replies: 19
    Last Post: 08-02-2011, 06:27 PM
  3. Casting long int to int
    By KBriggs in forum C Programming
    Replies: 15
    Last Post: 02-22-2011, 03:07 PM
  4. int casting for unsigned chars
    By DarkMasterBosel in forum C++ Programming
    Replies: 4
    Last Post: 01-09-2008, 03:31 AM
  5. Converting a Long to chars[4]
    By Russell in forum C++ Programming
    Replies: 15
    Last Post: 12-18-2002, 06:33 PM

Tags for this Thread