Free 173 Best Homemade Tools eBook:  
Become a founding member: 500+ tool plans, full site access, and more.

User Tag List

Results 1 to 4 of 4

Thread: Arduino Byte Juggling

  1. #1
    Supporting Member rgsparber's Avatar
    Join Date
    Nov 2012
    Location
    Phoenix, AZ
    Posts
    929
    Thanks
    474
    Thanked 1,937 Times in 498 Posts

    rgsparber's Tools

    Arduino Byte Juggling

    A very small population will have any interest in this topic. But if you are struggling with reads and writes of all data types to EEPROM, read onů

    http://rick.sparber.org/ABJ.pdf

    Your comments are welcome. All of us are smarter than any one of us.

    Thanks,
    Rick
    Rick

  2. The Following 4 Users Say Thank You to rgsparber For This Useful Post:

    Jon (06-01-2018), Seedtick (06-01-2018), volodar (06-17-2018), Workshopshed (06-02-2018)

  3. #2
    Supporting Member Workshopshed's Avatar
    Join Date
    Mar 2013
    Location
    North London, UK
    Posts
    204
    Thanks
    126
    Thanked 140 Times in 87 Posts

    Workshopshed's Tools
    Hi Rick, I had to do this kind of thing just the other day to send an integer over I2C.

    To multiply by 2 you can shift the number one to the left so to multiply by 256 which is 2^8 you can do.

    int b = a << 8;

    A technique I used back when I was coding for my ZxSpectrum in the 1980s as it did not actually have a multiply operator.
    Andy from Workshopshed
    "Making and repairing things in a shed at the bottom of the garden"
    workshopshed.com

  4. The Following User Says Thank You to Workshopshed For This Useful Post:

    volodar (06-17-2018)

  5. #3
    Content Editor
    Supporting Member
    DIYer's Avatar
    Join Date
    Aug 2013
    Posts
    3,088
    Thanks
    579
    Thanked 1,416 Times in 1,270 Posts
    Thanks Rick! We've added your Arduino Bit Shifting Method to our Miscellaneous category, as well as to your builder page: Rick's Homemade Tools. Your receipt:


  6. #4
    Supporting Member rgsparber's Avatar
    Join Date
    Nov 2012
    Location
    Phoenix, AZ
    Posts
    929
    Thanks
    474
    Thanked 1,937 Times in 498 Posts

    rgsparber's Tools
    Yes, <<8 should do a multiply by 256. Be carful on shifting right:

    long x = 0xFFEEDDCC;

    x= (x>>8) & 0xFF;

    Should produce 0x000000DD. Without the mask it would be 0xFFFFEEDD. It all depends on what you want.


    Post your reply!
    Join 42,532 of us and get 500+ tool plans, tool eBooks, build guides, and much more.



    eBooks for Supporters
    Last edited by rgsparber; 06-02-2018 at 11:39 AM.
    Rick

  7. The Following User Says Thank You to rgsparber For This Useful Post:

    volodar (06-17-2018)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •