Binary, Bits and Hexidecimal

I am developing code to decode handphone PDU.
I need to decode the hexidecimal in the PDU into binary bits first.
Then I need to take every 7 bits and form them into a character.
E.g. A201 will give 1010 0010 0000 0001
so the code will have to return 0100010 as ASCII for the first character, 1100000 as ASCII for the second character.
How can I go about doing that in the most efficient method.
I was thinking about converting to string first (0's and 1's), then manually extract out every 7 bits and do the processing. But that looks quite tedious.
Can anybody comment on this. Thanks!

Can't see where the 1100000 comes from.
Have you really got characters on 7 bit boundaries? That would be very unusual and inconvenient.
This kind of bit manipulation is best tackled with shift and mask operations of which this will be a particularly tiresome example. You need to load your hex data into an array of, I would suggest, ints, loading two hex digits at a time. Work in blocks of 7 bytes (7 bytes becomes 8 characters).
int[] codes = new int[7];
String hex = "a7882312228823"; // say
for(int i = 0; i < 7; i++)
     codes[i] = Integer.parseInt(hex.substring(2 * i, 2 * i + 2);Then you need to extract the characters by combining the appropriate bits from each byte of data.
char output = new  char[8[;
output[0] = (codes[0] >> 1);   // first 7 bits of code 0
output[1] = (codes[0] << 7) | (codes[1] >> 2); // bottom bit of first and 6 bits from second
output[2] = (codes[1] << 6) | (codes[2] >> 3); // bottom 2 bits of second and top 5 from third
... etc ...Of course it's a lot messier than this because your data might not be a multiple of 7 bytes and the data supply is obviously more complicated.

Similar Messages

  • SQL Server 2000 - Valid Binary datatype and valid character datatype:

    SQL Server 2000 - Valid Binary datatype and valid character datatype:
    Which is not a valid binary datatype :
    BIT , IMAGE, TMESTAMP
    Which is not a valid Character datatype :
    VARTEXT , BLOB , TEXT

    BOL 2014: "
    Data Types (Transact-SQL)
    SQL Server 2014 
    Data Type Categories
    Exact Numerics
     bigint
     numeric
     bit
     smallint
     decimal
     smallmoney
     int
     tinyint
     money 
    Approximate Numerics
     float
     real
    Date and Time
     date
     datetimeoffset
     datetime2
     smalldatetime
     datetime
     time
    Character Strings
     char
     varchar
     text
    Unicode Character Strings
     nchar
     nvarchar
     ntext 
    Binary Strings
     binary
     varbinary
     image
    Other Data Types
     cursor
     timestamp
     hierarchyid
     uniqueidentifier
     sql_variant
     xml
     table
     Spatial Types "
    LINK: http://msdn.microsoft.com/en-us/library/ms187752.aspx
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Separating 16 bits of data into one 12 bit and one 4 bit channel

    I have 16 bits of binary data and i'm trying to split these into one 12 bit and one 4 bit channel. I know that I could use something like:
    Dim Channel1 : Set Channel1 = Block.Channels.Add("Channel1", eI16)
    Channel1.Formatter.Bitmask = 4,095 'xxxx 1111 1111 1111
    but, i'm not sure how to grab those 4 bits out of the 16 bit channel1 and make channel2. It's like i almost need to say something like:
    Dim Channel2 : Set Channel2 = Block.Channels.Add("Channel2", eI16)
    Channel2 = Channel1.Formatter.Bitmask = 61,440 '1111 xxxx xxxx xxxx
    Can anyone help out???? thanks.

    OK...This is still straightforward. Her is what you want to do :
    CurrPos = File.Position ' remember where the block starts
    Set Block = File.GetBinaryBlock()
    ' set up all channels which can be read directly
    Dim Channel1 : Set Channel1 = Block.Channels.Add("Channel1", eU16)
    Dim Channel2 : Set Channel2 = Block.Channels.Add("Channel2", eByte)
    Dim ChannelPH : Set ChannelPH = Block.Channels.Add("Dummy", eU16) ' just a placeholder
    Dim Channel5 : Set Channel5 = Block.Channels.Add("Channel5", eU16)
    Dim Channel6 : Set Channel6 = Block.Channels.Add("Channel6", eByte)
    ' Now we need a block which has one channel only. This channel will be used to extract the bits.
    ' The block needs to start where the third schannel of the above block starts :
    File.Position = CurrPos + 2+1 ' 2 for the U16 channel, 1 for the byte channel
    Set Block = File.GetBinaryBlock()
    ' Set the scan width. This defines the gaps between the values of a channel
    Block.BlockWidth = 2+1+2+2+1 ' U16 + Byte + U16 + U16 + Byte
    Dim Channel3 : Set Channel3 = Block.Channels.Add("Channel3", eU16)
    ' .. apply bitmask and scaling (see my last example)
    ' Do the same for the second channel
    Set Block = File.GetBinaryBlock()
    ' Set the scan width. This defines the gaps between the values of a channel
    Block.BlockWidth = 2+1+2+2+1 ' U16 + Byte + U16 + U16 + Byte
    Dim Channel4 : Set Channel4 = Block.Channels.Add("Channel4", eU16)
    .. apply bitmask and scaling (see my last example)
    Do the same for the second channel
    I hope this works as expected. Let me know if you need more help...
    Andreas

  • Read binary file and convert to readable text

    I have a binary file which i want to read in and then convert it into readable text. How can i do this?

    I have a binary file which i want to read in and then
    convert it into readable text. How can i do this?Your question is a bit too vague to be answered. Here's an example -- suppose a file contains the bitstream 11011110101011011011111011101111. (just four bytes full of bits). If one 'converts' this bit stream using four byte big-endian integral values into a hexadecimal representation, the outcome would be 'deadbeef'. Using a little endian conversion, the outcome would be 'efbeadde'. All three text strings you're reading right now (the binary one, and both hexadecimal versions) are readable representations of the actual bitstream ... which one do you want?
    OTOH, if you want to know what's stored in a .class file (this is a Java forum isn't it?), have a look at 'pjava'; it comes with your SDK.
    kind regards,
    Jos

  • Binary bit test

    Hi,
    I need to test each binary bits using following logic equation.
    How do I do this?
    ((var & (1<<bit)) != 0)
    For example
    If var = 0111 and bit =2 (start from 0), so third bit of var is 1 and shift by two
    are equal, this equation will yield TRUE for third bit.
    Things I need to accoplish
    1. I need to compare every binary bit
    2. result should be in corresponing binary bit.
    Can someone show me how?
    thank you in advance,
    Do
    Solved!
    Go to Solution.

    In the Numeric >> Data Manipulation palette, there ist he logical shift function to move a bit.  You can also do boolean logic on integers.

  • Binary Bit Manipulation

    How can i convert a series of characters into corresponding binary bit pattern so that i can perform some bit manipulation (e.g. swapping bit position)?

    You can do that with plain chars; char is essentially an integer type and you can do all the bit manipulations with them as with other integer types.
    For example:
    char c = 'a';
    c = (char) (c | 0x80); // set the 8th bit on
    c ^= 5; // XOR with 5

  • Creation of Add-on package for 64 bit and 32 bit SAP Business One Client

    Please help me creating package for 64 bit and 32 bit SAP Business One. If Add-on executable is compiled with x86 option then there is no issue of connecting Add-on with 32 bit SAP Business one and if Add-on executable is compiled with Any CPU option then there is no issue of connecting Add-on with 64 bit SAP Business one. Problems are mentioned as below
    1. My Add-on uses MS ACCESS connection and the connection is read using Jet OLEDB 4.0 provider. It works fine for x86 compile mode but not when compile mode is Any CPU. I searched for the issue on Google and found a solution to change MS ACCESS connection provider to ACE.OLEDB.12.0 but again ACE provider is installed according to the Office version i.e. 32 bit or 64 bit office suite. If I install 32 bit ACE provider then Add-on executable compiled with x86 version is working fine but with Any CPU option throws error as provider is not registered on current machine.
    2. Secodly, our license validation activex dll is build using vb 6.0 and therefore when Add-on executable is compiled using Any CPU option, Add-on EXE cannot read from license dll. Any suggestion, how the activeX dll can be compiled whose component can be created from for X86 compiled exe and any cpu compiled exe.
    Please help because we are stuck in this issue and cannot move forward.
    Thanks.

    Hi Alejandro,
    That is one solution but did your add on used ms access connection? if you used Jet oledb to connection string or ace oledb connection string? what if 32 bit office is installed and what if 64 office is installed? how did you found the office version in install script? after determining the office version how did you installed Microsoft redistributable for ace oledb (32 bit or 64 bi )?
    I am sorry that I asked many questions but these are the problems where I am stuck with the addon installer?
    Thanks

  • Install sqldeveloper on windows 7 64 Bit and Oracle 11.2

    Hi,
    how can I find the rigth jdk. I installed JDK on C:\Program Files\Java\jdk1.6.0_23.
    I installed Oracle 11.2 including sqldeveloper. But I cannot find the correct folder to start sqldeveloper.
    Where can I find this path?
    When I include a path with java.exe I get the error "Unable to find a Java Virtual Machine. To point to a locacion of a Java Virtual Machine, pleaser refer to the Oracle9i Jdeveloper Install guide (jdev\install.html)" Where can I find this?
    Thank you for your help
    Siegwin

    I am on Windows 7 64 bit. I see that installing Oracle 11.2 database installs SQL Developer also but that doesn't work. I get the .bat file not found crap. What I then did was do a seperate install of SQL Developer for 64 bit, but that does NOT install the jdk.
    I then did the java install from:
    http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u25-download-346242.html
    I selected: jdk-6u25-windows-x64.exe
    I then point to the java.exe where this install loaded it (c:\program files\Java\jdk1.6.0_25\bin when I start up sql developer and it still gives the same error. I delete the SetJavaHome value in the sqldeveloper.conf file and try again over and over but it still gives the same error.
    So, I have windows 7 - 64 bit operating system. I have Oracle 11.2 database installed. I have a seperate installation of SQL Developer 64 bit and I have the java jdk for 64 bit installed.
    Nothing is working. Can anyone please steer me in the correct direction? Should I delete the second install of SQL Developer 64 bit and to an install of SQL Developer 32 bit?
    Please help

  • CC, CC 64 Bit, and CC 2014? WTF?

    It's bad enough Adobe can't figure out how to make the same features in one program work the same in a different program. To top it off, instead of improving what are now "apps" and integrating we now have more new programs to do the same thing (e.g. not just one for website creation, not just one for photos, not just one for illustrations, not just one for animation, etc...) and to top it off again they get rid of important programs like Soundbooth, and stop upgrading ones we need like Encore. I am beginning to think the CC is for Creative Chaos not Creative Cloud....
    So, I uninstalled my CS5 master suite finally and moved presumably up to CC. But, now do I not only have more than one program to do the same thing more now I also have 3 of each! Wow! That's STUPID. Sorry, I hate using that word, but what in the hell?
    Why is it when I go to my programs I have a CC version, a CC 64 bit, and now new to the Creative Chaos we have CC 2014 versions!!!!          What? Really? Someone, please help me maintain my sanity. Before I realized it I was using Premiere CC then I inadvertantly started using CC 2014. Then I was like "something is missing, oh, wait, what? there's more than one version of premiere in CC???" Then I realized "oh, there's 3 of Illustrator, Photoshop, and inDesign?
    I of course have a 64 bit system, so should I only use the 64 bit versions and just delete the shortcuts to the others? and when there isn't a 64bit version but instead just a CC and a CC2014 version, which do I use? I mean, I assume the CC 2014. But, in 2014 will something change, will I be like "damn it, I should have been using the CC not the CC2014"?
    Adobe, please clean up all your software, boil it down to just the ones we need, we don't need more than one program to do THE SAME THING. and once you boil it down, don't give us three versions of it, ask "do you want the 64 bit version or the 32" and we'll be happy to download precisely what we need. Or better yet, figure out a way to make it work with one program. And, of course while you're at it combine the CC and CC XXXX version of each, WTF???

    32bit programs are installed for those people who use plugins that have not been updated to 64bit
    CC and CC2014 have different source code bases, so they are different programs
    http://blogs.adobe.com/jkost/2014/06/installing-the-2014-release-of-creative-cloud.html
    This messages says (at least some) CC 2014 programs use NEW plugins https://forums.adobe.com/thread/1499663
    -so do not uninstall the older CC programs if you use plugins in your programs until you are sure you have plugins that work in CC2014
    If you are sure you don't need the old CC programs
    -http://helpx.adobe.com/creative-cloud/help/install-apps.html to install or uninstall
    -read reply #3 about the ORDER of uninstalling & installing https://forums.adobe.com/thread/1242671

  • What is difference between 32 bit and 64 bit sql server memory management

    What is difference between 32 bit and 64 bit sql server memory management
    Thanks
    Shashikala

    This is the basic difference...check if helps:
    A 32-bit CPU running 32-bit software (also known as the x86 platform) is so named because it is based on an architecture that can manipulate values that are up to 32 bits in length. This means that a 32-bit memory pointer can store a value between 0 and
    4,294,967,295 to reference a memory address. This equates to a maximum addressable space of 4GB on 32-bit platforms
    On the other hand 64-bit limit of 18,446,744,073,709,551,616, this number is so large that in memory/storage terminology it equates to 16 exabytes. You don’t come across that term very often, so to help understand the scale, here is the value converted to
    more commonly used measurements: 16 exabytes = 16,777,216 petabytes (16 million PB)➤ 17,179,869,184 terabytes (17 billion TB)➤ 17,592,186,044,416 gigabytes (17 trillion GB)➤
    As you can see, it is significantly larger than the 4GB virtual address space usable in 32-bit systems; it’s so large in fact that any hardware capable of using it all is sadly restricted to the realm of science fiction. Because of this, processor manufacturers
    decided to only implement a 44-bit address bus, which provides a virtual address space on 64-bit systems of 16TB. This was regarded as being more than enough address space for the foreseeable future and logically it’s split into an 8TB range for user mode
    and 8TB for kernel mode. Each 64-bit process running on an x64 platform will be able to address up to 8TB of VAS.
    Please click the Mark as answer button and vote as helpful if this reply solves your problem

  • Windows XP Pro (32-bit) and Vista Ultimate (64-bit) on the same Mac Pro HD?

    Has anyone been able to install both Windows XP Pro (32-bit) and Windows Vista Ultimate (64-bit) on the same dedicated Windows hard drive? I have four HD in my Mac Pro, and one of them is dedicated for Windows (and bootable via Boot Camp). I found the following technical articles about installing Windows XP & Vista on the same hard drive (using two separate partitions) using a VMWare machine as the test system:
    http://apcmag.com/howto_dual_boot_vista_and_xp_with_vista_installed_first__the_stepbystepguide.htm
    http://apcmag.com/howto_dualboot_vista_with_xp__stepbystep_guide_withscreenshots.htm
    Has anyone successfully installed Windows XP (32-bit) and Vista 64-bit) on the same NTFS partition?
    I already have Windows XP Pro (32-bit) SP3 installed on my single NTFS hard drive. I am looking for the best way to add the Vista 64-bit installation on the same hard drive.
    Any thoughts and advise are appreciated.

    Windows has its own list of boot OSs, and default, from msconfig. It will sit and wait for xx-seconds on startup in Windows if you want to boot from an alternate.
    As to whether Apple's OS Switcher (aka startup disk bootcamp control panel or tray icon) sees both, I had Windows Home Premium and Ultimate 64, and pretty sure OS X saw both. That was pre-Leopard and before there were 64-bit Apple drivers.
    I can't think of any scenerio of wanting to mix 32-bit and 64-bit on the same paritition, you realize you can't install the one over the other and must do a clean install.
    When I added a partition out of main partition (I wanted to put search index and page file on their own partition) those partitions aren't seen - are hidden - to Leopard.

  • Install demo of CS4 Web Premium-Photoshop Installs 64 bit and x86 versions but 64 bit does not work

    Just installed the CS4 Web Premium demo onto a brand new 64 bit i7 processor with Windows Seven Home Premium machine with 9gb memory. The install seems to be fine except it installed a 64 bit version as well as x86 version into different folders. The x86 version works fine but the 64 bit version does not.
    Every time I try to open a file using "Open With' I get the following message "The application was unable to start correctly (0xc000007b). Click OK to close the application."
    First of all why does it install both versions and why does it try to open everything in the 64bit version even after specifically telling it to open in the x86 version (even after setting the default file association to the x86 version.
    I would of course like to use the 64 bit veriosn but if it not going to work. I'll use the 32 bit version. I just wantto be able to right click my mouse and be able to "Open With". I can open Photoshop 32 bit and open the file that way but it is a pain to do that way.
    Any help would be appreciated

    Both are installed to allow you to use 32 bit plugins. As for the problem, you'll get far more attention in the Photoshop forum.
    Bob

  • I have a Windows 2003 Server 64-Bit, and when I upgraded to Firefox 4.0.1 now it won't run, it keeps saying to restart to complete the installation, but I've restarted theserver 4 times, and I still can't use it.

    I have a Windows 2003 Server 64-Bit, and when I upgraded to Firefox 4.0.1 now it won't run, it keeps saying to restart the computer to complete the installation, but I've restarted theserver 4 times, and I still can't use it.

    I ended up putting it in DFU mode.  It's kinda hard to tell it was in DFU mode because nothing showed on the screen, it was just black, but the sounds from the computer helped to tell me it was connected.
    Itunes still didn't recognize the device for whatever reason.
    So I used redsn0w.  I don't know if I can say that on these forums, but considering itunes was worthless at this point I am going to give credit where credit is due.
    Now I am giving itunes a second chance to upgrade to 5.1, if it doesn't work, well, back to redsnow and maybe I will even jailbreak it this time rather than just using the fecovery fix found under extras.

  • Trying to install iTunes 12.1 for Windows 8.1 (64-bit) and get Itunes error HRESULT: 0x800736B3

    Hello,
    I am Trying to install iTunes 12.1 for Windows 8.1 (64-bit) and I get an Itunes window with an error that says:
    An error occurred during the installation of assembly 'Microsoft.VC80.CRT,type="win32",version'8.0.50727.6195",publicKeyToken="1fc8b3 b9a1e18e3b"processorArchitecture="amd64". Please refer to help and Support for more information.HRESULT: 0x800736B3
    I already:
    - Uninstalled all old Itunes versions.
    - Tried a clean reboot to install the new version,
    - Installed the security update’ Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package ATL Security Update’
    But I still get the same error.
    Can someone help?
    Thanks!

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    If you still have trouble you might consider installing the alternate version iTunes 12.1 for Windows (64-bit — for older video cards) where you can download a 64-bit installer for the 32-bit version of iTunes that works with older video cards. This version may also be useful for anyone who is unable to get the 64-bit version of Apple Application Support to install when using the itunes6464setup file, or has trouble with playback of certain video files despite having QuickTime installed.
    tt2

  • Is HP Smart Web Printing compatible with Windows 7 Ultimate 32 bit and Internet Explorer 8 and 9?

    Is HP Smart Web Printing compatible with Windows 7 Ultimate 32 bit and Internet Explorer 8 and 9?

    HP Smart Web Printing has been replaced with HP Smart Printing.  It does support Windows 7 and IE 6 to IE9.  See this page for information.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

Maybe you are looking for

  • Ical monthly view on ipad not showing time

    My ical preference from my laptop is not carrying over to ipad.  How can I get ical (in monthly view) to show appointment time withou

  • Acrobat Pro 8.1.12 and Acrobat Reader 9.0 crashing when trying to print

    The subject line says it all, but I upgraded my MacBook Pro to Leopard 10.5.5 and now when I select File | Print I get the spinning beach ball than Acrobat crashes. Now oddly, if I use Acrobat Reader 7.0.9, it prints perfectly. But have Acrobat Pro 8

  • Getting back to 8128kbps sync :P

    My stats are ADSL line status Connection Information Line state Connected Connection time 2 days, 02:25:25 Downstream 7,360 Kbps Upstream 448 Kbps ADSL Settings VPI/VCI 0/38 Type PPPoA Modulation G.992.1 Annex A Latency type Fast Noise margin (Down/U

  • Modifiying selection screen of report RIQMEL20 coming from LDB 'QMI'

    It is intended to modify the SAP standard report RIQMEL20 . This report RIQMEL20  is using the Logical Data Base "QMI" for the selection screen block & data selections which we need to modify. That means we need to modify this SAP Standard LDB "QMI"

  • Unable too upload pictures

    Hi plzzzz someone HELP!! Up untill a couple wk ago I was ale too upload pics from my blackberry too the groups I've joined on facebook,I can upload pics to my facebook wall and too my albums...but I can't upload pics onto my group sites....its drivin