4 Replies Latest reply on Nov 15, 2014 5:29 PM by Reach41

    integers in Edison Arduino IDE

    Reach41

      Bit 31 is the sign bit in integers, running the Arduino IDE for Edison.  Interesting, didn't see that mentioned anywhere, but a good thing.  Arduino boards (most of 'em) have 16 bit integers.  Might be a good selling point to mention with the Arduino breakout boards.

        • 1. Re: integers in Edison Arduino IDE
          deium

          The sign bit is always the most significant bit in unsigned Integers, whether it is 8, 16, 32, 64 or higher (Bytes, words, integers, int64's).

          • 2. Re: integers in Edison Arduino IDE
            Reach41

            I don't know a whole lot, but I did know that!  What I was pointing out is that the type int on the Arduino is 16 bits.  The Edison, run on the Arduino breakout board, can use the custom Arduino/Edison IDE, using Arduino libraries.  Some functions from that IDE assume the integer to be 16 bits, which on the Edison is 32.  I haven't seen that noted anywhere in the literature about the Arduino/Edison IDE, so thought I'd mention it (found out the hard way).

            • 3. Re: integers in Edison Arduino IDE
              KurtE

              Yes I have been bit before on by code including libraries who expect integers to be a a specific siz.  This is not unique to Edison as it is also true for Arduino Due as well as Teensy 3/3.1.  Note the Arduino reference talks about this Arduino - Int

               

              if your code needs specific sizes, it should use some of the stdint sized types like int16_t uint16_t

              • 4. Re: integers in Edison Arduino IDE
                Reach41

                I was fiddling with SPI, and data transmission preparation.  Wanted to send an Integer to an Arduino, so was using the Arduino Cish lowByte, highByte functions.  That was easy enough, but wanted to check it for sending negative numbers, and it was AFU.  That's how I found out.