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
    1,023
    Thanks
    536
    Thanked 2,188 Times in 536 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

    173 Best Homemade Tools eBook
    Rick

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

    Jon (Jun 1, 2018), Seedtick (Jun 1, 2018), volodar (Jun 17, 2018), Workshopshed (Jun 2, 2018)

  3. #2
    Supporting Member Workshopshed's Avatar
    Join Date
    Mar 2013
    Location
    Ayrshire, UK
    Posts
    209
    Thanks
    128
    Thanked 145 Times in 89 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 (Jun 17, 2018)

  5. #3
    Content Editor
    Supporting Member
    DIYer's Avatar
    Join Date
    Aug 2013
    Posts
    3,085
    Thanks
    637
    Thanked 1,555 Times in 1,394 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
    1,023
    Thanks
    536
    Thanked 2,188 Times in 536 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.



    173 Best Homemade Tools eBook
    Last edited by rgsparber; Jun 2, 2018 at 10:39 AM.
    Rick

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

    volodar (Jun 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
  •