+ Reply to Thread
Results 1 to 13 of 13

Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

Hybrid View

  1. #1
    Registered User
    Join Date
    02-13-2014
    Location
    Somewhere, Rainbow
    MS-Off Ver
    Excel 2007
    Posts
    20

    Question Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    All,

    I have several fields where I am attempting to convert a signed binary angle (either 16 or 32 bit) into hexadecimal. Normally I would use the Windows programmer calculator, but I can't seem to use the decimal period on that program for some reason (guess there's an issue converting the decimal period into hex with that program?).

    Here are specific examples:

    1) Signed Binary Angle - 16 bit: My value range is from -90.0000 to +89.9973 and I want to convert this into a 2-byte hexadecimal.

    2) Signed Binary Angle - 32 bit: My value range is from -90.000000000 to +89.999999958 and I want to convert this into a 4-byte hexadecimal.

    If I was inputting my value into cell A1 and having this conversion and reporting take place in cell B2, what function would I use? I attempted to use the following with no avail: =DEC2HEX(A1,4).

    Any help would be appreciated! Thanks for reading.

    Respectfully,
    Talamon
    Last edited by Talamon; 02-18-2014 at 02:43 PM. Reason: Changed from BIN2HEX to DEC2HEX

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    I think the function you're looking for is DEC2HEX
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Registered User
    Join Date
    02-13-2014
    Location
    Somewhere, Rainbow
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    Quote Originally Posted by daffodil11 View Post
    I think the function you're looking for is DEC2HEX
    My apologies as I mis-typed in my original post. However, the DEC2HEX function still did not work as it is having a hard time converting the decimal point.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    Give some examples of the conversions you want.

    As an aside, a 32-bit value would take 8 hex characters to encode.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    I think this is what you asked for:

    A
    B
    C
    1
    16-bit
    2
    -90.0000
    8000 B2: =RIGHT(DEC2HEX(32768 * $A2 / 90), 4)
    3
    89.9973
    7FFF
    4
    5
    32-bit
    6
    -90.000000000
    80000000 B6: =RIGHT(DEC2HEX(2147483648 * $A6 / 90), 8)
    7
    89.999999959
    7FFFFFFF


    However, one would more typically encode angles between -180 and +180 to get the circularity.

  6. #6
    Registered User
    Join Date
    02-13-2014
    Location
    Somewhere, Rainbow
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    Quote Originally Posted by shg View Post
    I think this is what you asked for:

    A
    B
    C
    1
    16-bit
    2
    -90.0000
    8000 B2: =RIGHT(DEC2HEX(32768 * $A2 / 90), 4)
    3
    89.9973
    7FFF
    4
    5
    32-bit
    6
    -90.000000000
    80000000 B6: =RIGHT(DEC2HEX(2147483648 * $A6 / 90), 8)
    7
    89.999999959
    7FFFFFFF


    However, one would more typically encode angles between -180 and +180 to get the circularity.
    I am working out the conversions of Latitude and Longitude from the decimal to the hexadecimal (hence why the -90 through ~+90).

    Why my book calls it a "Signed Binary Angle" is a mystery for me...

    However, your solution works for my particular problem. Thanks for your support shg!

  7. #7
    Registered User
    Join Date
    02-13-2014
    Location
    Somewhere, Rainbow
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    Quote Originally Posted by shg View Post
    I think this is what you asked for:

    A
    B
    C
    1
    16-bit
    2
    -90.0000
    8000 B2: =RIGHT(DEC2HEX(32768 * $A2 / 90), 4)
    3
    89.9973
    7FFF
    4
    5
    32-bit
    6
    -90.000000000
    80000000 B6: =RIGHT(DEC2HEX(2147483648 * $A6 / 90), 8)
    7
    89.999999959
    7FFFFFFF


    However, one would more typically encode angles between -180 and +180 to get the circularity.
    Out of curiosity, how did you come up with the "32768" and "2147483648" values?

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    IF you scale between -180 and 180 instead of -90 and 90, it's a very easy format to use for trig functions, because all values are valid, they can be regarded as signed or unsigned, and they wrap circularly the way trig functions do, i.e., sin(361 degrees) = sin(1 degree)

    I am working out the conversions of Latitude and Longitude ...
    Perfect point; longitudes range between +/-180, not +/-90.

  9. #9
    Registered User
    Join Date
    02-13-2014
    Location
    Somewhere, Rainbow
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    Quote Originally Posted by shg View Post
    IF you scale between -180 and 180 instead of -90 and 90, it's a very easy format to use for trig functions, because all values are valid, they can be regarded as signed or unsigned, and they wrap circularly the way trig functions do, i.e., sin(361 degrees) = sin(1 degree)


    Perfect point; longitudes range between +/-180, not +/-90.
    Agreed, but my question was only working on the latitude portion. My thoughts were that, once I figured out how to work the latitude (with the help of kind and smart folks like yourself), I should be able to modify the formula for the longitude portion.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal


  11. #11
    Registered User
    Join Date
    02-13-2014
    Location
    Somewhere, Rainbow
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    Quote Originally Posted by shg View Post
    Those articles made no sense to me. Can you just give me the 'dumbed-down' version?

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    Where are we starting from? Do you know how numbers are represented in binary? Do you know what twos-complement means?

  13. #13
    Registered User
    Join Date
    02-13-2014
    Location
    Somewhere, Rainbow
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Signed Binary Angle (16 or 32 bit) converted into Hexadecimal

    Quote Originally Posted by shg View Post
    Where are we starting from? Do you know how numbers are represented in binary? Do you know what twos-complement means?
    I have never dealt with binary or hexadecimal in great detail before a week ago. I'm trying to write a spreadsheet that takes people's inputs and converts it from a decimal into a hexadecimal. Here is my project (attached):Project_Help.xlsx

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Hexadecimal to binary
    By me@home.net in forum Excel General
    Replies: 10
    Last Post: 06-16-2016, 10:32 AM
  2. [SOLVED] Hexadecimal 'of a cell' to Binary
    By ctrc in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-18-2013, 04:28 AM
  3. Excel 2007 : Hexadecimal to Binary conversions
    By dfoster in forum Excel General
    Replies: 6
    Last Post: 02-08-2012, 03:12 AM
  4. [SOLVED] Hexadecimal to Binary Conversion
    By sean_f in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-04-2006, 04:05 PM
  5. Formula for converting Binary to Hexadecimal
    By Teraawete Tekena in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-23-2006, 03:20 AM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1