Bit pattern, again

I want to get to know the bit pattern of a double or float variable.
Originally I thought that I can use Double.doubleToLongBits() or Double.doubleToRawLongBits() to return a long variable and then Long.toBinaryString() to see the bit pattern.
But the bit pattern didn't make perfect sense when compared to the IEEE specs for floating point arithmetic.
The problem appears to be that - according to the Javadoc - there is no guarantee that doubleToLongBits() and the other one return a value that really reflects the bit pattern completely. The only guarantee there is - apparently - that the long value returned will produce the same double value again when it is passed to Double.longBitsToDouble() . But that is not a guarantee that the bit pattern of the long variable returned really reflects the bit pattern of the double. And in reality it apparently doesn't.
Looking at the source of doubleToLongBits() isn't possible, because both are native methods.
Am I making myself clear? If not, never mind. The important thing now is:
I'm back at bit shifting. But I can't do a bitwise & between a double and a long. So, this doesn't work:
public class DoubleBits2 {
    public static void main(String[] args) {
        double d = 1.0;
        long val = 0x8000000000000000L;
        if ( (d & val) == val){
            System.out.print( '1' );
        else {
            System.out.print( '0' );
        val = 0x4000000000000000L;
        for ( int i = 1; i < 63; i++ ){
            if ( ( d & val ) == val ){
                System.out.print( '1' );
            else {
                System.out.print( '0' );
}Any advice?
It never hurts to ask. :-)

>
The problem appears to be that - according to the
Javadoc - there is no guarantee that
doubleToLongBits() and the other one return a
value that really reflects the bit pattern
completely. The only guarantee there is - apparently
- that the long value returned will produce
the same double value again when it is passed
to Double.longBitsToDouble() . But that is not
a guarantee that the bit pattern of the long
variable returned really reflects the bit pattern of
the double. And in reality it apparently
doesn't.I have tranferred IEEE values from C to Java anc Java to C using doubleToLong().
Looking at the 1.5 Javadoc I don't see where it says it does not return the IEEE format -
public static long doubleToLongBits(double value)
Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.
Bit 63 (the bit that is selected by the mask 0x8000000000000000L) represents the sign of the floating-point number. Bits 62-52 (the bits that are selected by the mask 0x7ff0000000000000L) represent the exponent. Bits 51-0 (the bits that are selected by the mask 0x000fffffffffffffL) represent the significand (sometimes called the mantissa) of the floating-point number.
If the argument is positive infinity, the result is 0x7ff0000000000000L.
If the argument is negative infinity, the result is 0xfff0000000000000L.
If the argument is NaN, the result is 0x7ff8000000000000L.
In all cases, the result is a long integer that, when given to the longBitsToDouble(long) method, will produce a floating-point value the same as the argument to doubleToLongBits (except all NaN values are collapsed to a single "canonical" NaN value).

Similar Messages

  • High frequency bit pattern evaluation

    I am trying to use a 6601 counter/timer to count the bits in a high speed serial output from a linear encoder.  I've successfully used the counter/timer card to clock and reset the encoder, but I'm having trouble using my third counter input to correctly tell me where the edges of the bit pattern are.  I realise I should probably have bought a serial card to do the job properly, but what the heck ;-).
    I'm using Borland C++Builder, by the way.
    I aimed to use the clock signal to latch the buffer and record a one or a zero in my edge count array to work out whether or not the data signal had changed state.
    The signal relationships are thus:
    I generate a finite pulse train 24 pulses long at a frequency up to 2MHz on CTR0. This output has a retriggerable start trigger on its CTR0GATE, which is generated at CTR2 (which I have to use instead of CTR1 as CTR1 seems to be affected by what is happening on CTR0 in some way that I do not fully understand). 
    The CTR0 output is sent to the transducer, which returns a serial bit pattern starting with the most significant bit and ending with the least significant bit.  CTR0 is high at idle as this is what the transducer requires to reset to its first bit.  If there is no pause at the end of the clock train the encoder returns the same value irrespective of where it actually is (like a sort of sample/hold). 
    The data return from the transducer comes in on CTR3SOURCE, which uses the CTR0 clock coming in on CTR3GATE to latch the buffer and reload the counter.
    CTR2 is a free running infinite pulse train that is usually low but goes high shortly after the end of the pulse train on CTR0 to retrigger CTR0 as described above.
    There is some crosstalk on the transducer output from the clock signal, but since I am having trouble reading back the edge count array I can't really tell if it is causing any problems.  However, I do know that the linear encoder is behaving as expected.
    Thanks for any ideas anyone might have!
    Des

    Hi,
    Thanks for posting the problem on the NI forum.
    You wrote:
    >I generate a finite pulse train 24 pulses long at a frequency up to 2MHz on CTR0. This output has a retriggerable start trigger on its >CTR0GATE, which is generated at CTR2 (which I have to use instead of CTR1 as CTR1 seems to be affected by what is happening on
    >CTR0 in some way that I do not fully understand). 
    Essentially when generating a finite pulse the counter channels are paired up i.e. it uses the gate to give the counter pulse out on CTR2. In other words it is internally routed in the maner you have describe hence its not an unexpected behaviour. CTR 1 is used internally to genetate the pulse at CTR 2.
    I was wondering whether you could perhaps provide a timing diagram of the counter pulses recieved.
    Kind Regards,
    Kurt

  • How to count bit patterns in a file ?

    Think of the following:
    You have two files that you want to compare bit by bit.
    A file has been send the other one has been received.
    The two files can be of different size (Connection lost).
    But you not only want to know how many bits are different you want also to know the run length of the different bits.
    For example:
    File 1:                      1010101011101010111101011001
    File 2:                      1011101010001101010111010101
    What is the result ?
    Xor File1 and File2:   0001000001100111101010001100
    Run Length 1:           3
    Run Length 2:           2
    Run Length 3:           0
    Run Length 4:           1
    I hope I didn't make a mistake.
    Think also of using a blocksize for comparison.
    Maybe you don't want to compare the files as a whole but want to know the number of errors for every block that is maybe 256 bit or 1024 bit. So read the files block by block, xor the blocks and count the bit errors by their run length.
    So how can I get this result in LabView ?
    Which data types do I have to take for comparison ? Which VIs do I have to use ?
    Thanx for help and your time

    Hi Allen,
    thanks for your posting.
    I have now a working version.
    For my as LabView newbee this was really hard work.
    So how many bit patterns of "1" or "11" or "111" or "1111" are in the xor result of the two files ?
    Or you can also ask: How long is the error (Burst error) ? And how often does it occur ?
    Look for example for block error codes and this stuff.
    Attached is the VI and two small text files (Both 10 Bytes).
    I've tried a blocksize of 10 Bytes and also 5 Bytes.
    The result is:
    1     2     3      4
    16   5     1      1
    So there 16 errors of run length 1, 5 of run length 2 and so on.
    Would be also nice to count special bit patterns like '1001101010111" or something like that.
    But I think this is more easy.
    Not the pattern is searched. The first 1 and the following 0 is searched.
    The run length is used as index.
    Attachments:
    Filediff 4.vi ‏32 KB
    Kopie1 von REAMDE.txt ‏1 KB
    Kopie2 von REAMDE.txt ‏1 KB

  • Bit patterns in Java

    How do I create a bit pattern (bit string, bit stream?) in Java?
    What I'd like to do is to contract data and use a bit pattern instead of the Java built-in standard classes. With what Java tools/classes can I achieve this?
    Example: Storing personal data for a high school student:
    Bit 1 (nationality): American=0, Foreigner=1
    Bit 2 (sex): male=0, female=1
    Bit 3-4 (grade/class): freshman=00, sophomore=01, junior=10, senior=11
    And so on...
    The bit pattern is supposed to be able to hold a lot of information, at least a 100 bits or so.
    Thanks!
    /peso

    peso wrote:
    Thanks for your reply JoachimSauer. You're right in what you're saying that space is cheap and all, but in this case it's essential for my application that I store the information in as few bits as possible.Why is that, I wonder? Out of curiosity. Are you storing/transfering so many records or is the space/bandwidth so limited?
    And I'm also interested in learning the best way to create and build a bit pattern with the information I have.
    Say I have about a hundred different strings containing different information:
    String nationality = "American";
    String sex = "Male";
    String grade = "Sophomore";
    String age = "17";
    Etc...
    I could store this as for example "American;Male;Sophomore;17".The first step would be to get rid of any Strings and transfer that to some better-fitting datatypes. For example create an enum for nationality (even if it only got the values AMERICAN and FOREIGN, I wouldn't call that nationality, btw).
    Then an enum for the sex and grade. And use an int to store the age.
    Because using Strings for things which aren't arbitary (or at least somewhat freeform) character strings is ... wrong.
    But what I'd like to do is to encode this information in a bit pattern like for example "0 0 01 10001" and then converting the bit pattern into a string of ASCII characters by taking lets say 5 bits at a time. Say the beginning of my bit pattern would look like "01011 00101 11001 11110 01000". That would produce the following string with ASCII characters (if I add 33 to the value in order to get a value which represents a writable ASCII character) ",&:?)".I'd use the Base64 encoding, if an ASCII-representation was absolutely needed. But if you really need to use as little space as possible, then you should keep a binary format.
    So the question is, what's the best way to build my bit pattern? Say I need 124 bits for all my information. Do I create a byte array of size 16 and manipulate each byte by shifting and masking? Or is there another way to do it?Use a BitSet.

  • Boot failure - white screen corrupted with yellow repeated bit-pattern.

    Hi
    I have had a quick look at the postings esp those with pictures and can't find a similar prob to mine. My white 24" iMac hasn't been able to boot for months now, except a couple of times but it then subsequently started playing up. As well as a boot failure the white boot screen has yellow bit-patterns on it, usually horizontal or speckled. I have been able to run the diagnostics program from the OSX disc but it didn't find any problems. The computer displays and animates the spinning wheel while booting, but overlaid on the corrupted white screen, and then 99% of time gets no further.
    I have made 5 screenshots with my 3G iPhone, the first two are of one boot attempt, the third is another boot attempt (note slightly different bit pattern - this one is the most common I get) and last two are of a successful boot attempt into AHT (Apple Hardware Test). If anyone recognizes this type of screen problem please do reply.
    Standard boot attempt (1) - two photos showing spinning wheel:
    https://files.me.com/funkypuck/e0nt8c
    https://files.me.com/funkypuck/nts1nu
    Standard boot attempt (2) - one photo showing typical screen corruption:
    https://files.me.com/funkypuck/izjv0e
    Boot into Apple Hardware Test - two photos of same area (just because 3G camera not so hot):
    https://files.me.com/funkypuck/q64kgt
    https://files.me.com/funkypuck/e72fkd
    Many thanks

    Hi, I am having a similar problem from what you described, but I can't even get the disk up and running for a clean install with Snow Leopard.  I'm curious if you have found a solution.  I fairly certain that it is not an issue with the hard drive. 

  • How do I synchronize two 6534 devices to output 45 bit pattern?

    I am using a PXI chassis with two 6534 cards. I am generating a 45 bit wide data pattern and sending 32 bits per update to one device buffer and 13 bits to the other. However my trigger is an external clock that is always running. This means that the data is sent to the outputs as soon as it arrives at the device buffer. On a logic analyser i've seen that the data is not in sync. I therefore need to make sure that the data on each channel is synchronized. How can this be done?

    Coxy
    Is it that you want to make sure the two 6534 moduals are in sync sending out the data? If this is the case, and you're doing pattern I/O, you can use the same clock for both moduals. (This can be done internally routing one clock to the a RTSI line.) Let me know if I am understanding your application wrong.
    Brian

  • Need access to Photoshop CS6 32-bit again

    I downloaded and installed both the 64 and 32 bit versions of Photoshop. Later I uninstalled the 32bit version thinking I did not need it. Now I found out I need it to run some third party plugins. But I can not seem to get Cloud to allow me to download the 32 bit app again.

    Hi Bphipps343793,
    How did you uninstall just the 32-bit version? I would run the Photoshop uninstaller via
    Control Panel > Programs and Features (Vista/Win 7) or Add/Remove Programs (XP)
    Applications > Utilities > Adobe Installers
    After uninstalling try just reinstalling Photoshop again, you should have both the 32 and 64-bit versions again.
    -Dave

  • Keyboard sound issue / camera overheats a bit faster once again after 5.1.1

     Let us know when you do 

    i dunno i think there is an issue with the keyboard sound. Like for example when you type "Hello" supposedly you will hear 5 clicks right!?  but for some reason you will only hear 4.  Its like the phone is having hard time catching up on what you are typing. Its not synchronize.  Also camera overheat a bit faster again. not happening with the previous version done hard reset and reupdate using pc companion still the same.

  • Trouble getting 2 8-bit ports on a 6025E DAQ to work concurrently

    Hello,
    I am using a PCI-6025E DAQ card in a PC running WinNT, and am trying to interface to it with Labview 6.0.2.
    More specifically I try to use portA and portB at the same time (two of the three digital I/O ports that the card has.)
    I am trying to write and hold a digital 8-bit pattern on portA, then write another pattern on portB.For this purpose I use the "Write to Digital Port.vi" twice, within another VI. I slightly modified it with "error in" and "error out" terminals to ensure they operate in the correct sequence, but I doubt this is causing my problem.
    My problem is that after I write (successfully) to portA, portA is grounded (reset?) before proceeding to write to portC (again su
    ccessfully.)
    I opened up the VI and cannot seem to find a reset command anywhere in it -though I don't understand everything in there, so I could be missing it.
    How do I get to use two copies of this VI as sub-VIs without having them interfere with each other? I need to hold their outputs to the correct value simultaneously while a third VI executes (it involves the counter.)
    Thank you,
    -Alexander

    Alexander,
    The three additional digital ports of the PCI-6025E use the 8255 chip. When any port on this chip (Port A, B, or C) is configured, all of the ports will be reset. To get around this, you will just need to configure all of the ports initially and then perform the reading/writing within your application. The link below describes the 8255 and how to effectively program with this chip. I hope this helps.
    Why Do All My Digital I/O Ports Reset When I Configure One Port?
    http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/3e25a9780f2c48b986256120005af098?OpenDocument
    Regards,
    Todd D.

  • ITunes says that my iPod cannot be used because the required software is not installed.  Says to install 64-bit version.  Problem is 64-bit version is installed already.

    I have a 64 GB iPod operating on iOS 5.1.1 (says software is up to date).  I finally was able to download iTunes 64 Bit to my computer and open it.  Now when I connect my iPod to the computer, I get a message saying "This iPod cannot be used because the required software is not installed.  Tun the iTunes installer to remove iTunes, then install the 64-bit version of iTunes."    I have removed iTunes from my computer and downloaded the 64-bit version again and installed it.  I still get the same message.

    Hi antiklady,
    I see that you may be having an issue with compatibility of iTunes when connecting your iOS device. This sort of issue can arise if you have two versions of iTunes installed on your computer, which I feel may be the case. Here is an article that can tell you how to identify the version of iTunes that you have open:
    iTunes: How to find which version you are using - Apple Support
    http://support.apple.com/en-us/HT201521
    If the version of iTunes that is opened is not the version you are required to use for the iOS device in question, try searching through your computer or applications folder to see if there may be two versions of iTunes installed on your computer. Then, uninstall the version that is incompatible using these steps:
    Remove and reinstall iTunes and related software components for Windows Vista, Windows 7, or Windows 8 - Apple Support
    http://support.apple.com/en-us/HT1923
    Take care, and thanks for visiting the Apple Support Communities.
    -Braden

  • Can't install iTunes 10.5 on my windows 7 64 bit laptop!!!!

    I've been trying to install/update my itunes 10.4 to itunes 10.5 but every time I keep getting an error. I've tried reinstalling it, removing and or deactivating firewalls and anti virus software. running a system clean up, rebopoting my laptop, and removing everything apple from my HD and reinstalling it all back on and it still wont work. Anybody else have this problem? Here is the error message im getting.
    Im running windows 7 64 bit, everything updated on the windows side

    Are you using the 32 or 64 bit version of iTunes. Also, double check to ensure you are running an x64 version of Windows. If you are running 64-bit Windows and 64-bit iTunes, it should work, but try the 32-bit one. If you are running x64 Windows and 32-bit iTunes, again, it should work, but try the 64-bit. If you are running x86 (32-bit) Windows, you will need to run the 32-bit version of iTunes.

  • TS1717 I've had it...tried everything under the sun to install itunes on my windows 7 64 bit machine.....spent hours trying...no go...android here i come

    I've tried everything and nothing but a pain.
    Can not get itunes installed on my windows 7 64 bit laptop
    I had a desktop with XP and no problems,.....ever......
    Im about to get rid of my iPhone and go with android,
    I've never had so much trouble.
    I have tried everything recommended in forums, several times.
    Nothing ....

    Are you using the 32 or 64 bit version of iTunes. Also, double check to ensure you are running an x64 version of Windows. If you are running 64-bit Windows and 64-bit iTunes, it should work, but try the 32-bit one. If you are running x64 Windows and 32-bit iTunes, again, it should work, but try the 64-bit. If you are running x86 (32-bit) Windows, you will need to run the 32-bit version of iTunes.

  • IFilter 9 64-bit deletes files and moves them into idividual folders

    Our fire department scanned thousands of documents using Adobe Capture and stored them on a Windows Server 2008 R2. We then installed iFilter 9 64-bit so Windows Search could make these documents searchable.  The second day iFilter was installed I noticed some unknown folders in the root of c: with names such as A9R2f4-115f67e8.  By the third day these had grown to thousands of folders, each with one PDF document in it.  I recognized the files as the ones that had be captured with Adobe Capture and checked their original location and found the files missing.  It appeared that in indexing the files Windows Search with iFilter was moving each file into an individual folder.  I removed iFilter and the problem stopped.  Luckily I had a backup and was able to restore the files to their original location.
    Months later I installed a new server at a different location.  Thinking this was possible a conflict with another program or service on the original server I copied the adobe documents onto this new and clean server and installed iFilter 9 64-bit.  Again, the first day things look fine but on the second day the folders once again started showing up in the root of C:, again I removed iFilter 9 and the problem went away.
    This would appear to be a bug in the program since it has happened to two server, one a brand new Dell R710 with nothing on it except the server software and Adobe iFilter and the PDF files that were captured using Adobe Capture. I have called Adobe and I was told they do not provide support for iFilter other than this forum.  If anyone has any suggestions I would really appreciate the help.

    Erwin,
    I was not able to systematically examine this issue, because it occurred on a production system and, of course, I uninstalled the Adobe iFilters as soon as I read that they may delete pdf files. Before the uninstallation I noticed the AR9 folders appearing on c:\ and moved them from time to time to another folder. Using the search function inside this folder, I found that all files were present in duplicate at least. I concluded, that after moving the AR9 folders they were recreated containing the same files. Consequently, these files cannot have been deleted. Searching for the origin of these files I found that they were part of pdf portfolios, therefore my conclusion that they are part of the indexing mechanism of the portfolios. What I have not done (and what I am not going to do since it is a production system) is to fill a folder with pdfs and track what is happening to the files.
    In case of my server, I think that the iFilters did not delete any files. Of course I cannot say what happens on other systems. I am definitely not going to reinstall the iFilters before knowing what they a really doing to the files.
    Not sure if this is of much help
    Michael

  • 11.1.0 on linux 64 bit

    I've been using 32 bit linux in production for years without major issues. I have some new 64 bit servers and decided to look at the 64 bit db again. I did this along time ago, but found we had some incompatibility issues with other required software. So, I installed 11.1.0.6, but I find I cannot patch to 11.1.0.7 cleanly. I have a SR open on this, but I just wonder if this is really a viable path or am I asking for headaches down the road. It seems creepy that the first thing I try to do with it goes into the toilet. Are people using 64 bit oracle db? On which OS? I'm on Red Hat 4. Perhaps that is the issue. Maybe Oracle Corp is dumping on RH like they did on Sun in the past. Is Oracle linux required now? I don't mean on paper, I mean in reality? I mean really when you think about it, why would that not be the case?

    Thanks, that's interesting to know. I've seen that sort of thing before where different verisons of the db only worked cleanly on a certain version of the OS, otherwise it was just a bunch of headaches, "supported" or not. Hmmm, RH5. I wish the support matrix would say what really works instead of what is sort of is supported.
    Edited by: user629260 on Aug 7, 2009 6:39 AM
    Edited by: user629260 on Aug 7, 2009 6:39 AM

  • Video bit rate after conversion

    Hello everyone,
    Im wondering, if i have a file of x format, with 50Mb video bitrate, and I convert it using compresor 4 to ProRess 422, the result will give me a video with .mov extentin with video bitrate around 120 Mb, if I convert it to Proress (LT) it will give a result of around 70Mb video bit rate.
    Will the new outputs have true clean bit rate, I mean the margine btwn 50Mb and 120 or 70, will it be showed , so will the new video show a better result, or it will just show same result at 50Mb. 2nd, in case I reconvert from Proress 422 (LT) (70 Mb) to anyformat (not necessarly using cpmpressor 4) to any format havn video bit rate again 50 Mb, will the output be the same of the original 50Mb that had the x

    If you are concerned about this issue, do your own tests.
    Make a copy of a representative sample of your original material in ProResHQ, one in ProRes422 and one in ProResLT
    Put your original in a ProRes4444 timeline in V1 and one of the copies in V2. Apply the difference matte.
    Do you see anything? Do the same process for all three variants of ProRes.
    Now, convert the material to your delivery format and put it back in the ProRes4444 timeline on V1 and one of the ProRes copies on V2 and apply a difference matte. Again, what do you see?
    If you see a solid screen of black, there is no measurable difference between the files.
    If you do see artifacts, do an A/B comparison on a good grading monitor - sometimes stuff that shows up in the difference matte can not be seen by the eye even in dedicated A/B testing.
    Have fun.
    x
    fwiw - all ProRes varients are 10 bit codecs. They are designed to absorb a great deal of editing/compositing without degrading. This is why you want to get any material that was acquired in a long GOP, compressed format OUT of that format as soon as possible if you will be grading, compositing or doing any work beyond simple cuts.

Maybe you are looking for

  • Display resolution and appeaarance

    My 13" display got oversized, but it is set at the highest resolution. I have set it lower and then reset it restarted computer, also did hard restarts.What next? Cat walked across keyboard to make it happen. Thanks!

  • Scanning of QR Code.

    How to scan qr codes in Lumia 535 Moderator's note: The subject was edited as the post was moved to a more appropriate board.

  • Coding  For T-Code AFAB

    Hi, there is a transaction called AFAB for depriciation run. In that transaction, there is a option where one can go for test run. I want code for that test run option & for the ALV used coz I want to display the same in my report. Thanks & Reg, Nish

  • Oracle Small Application

    Hi, we are developing risk management solution for small ang big organisations, the problum is that when ever we recommend oracle solution to our clients they allways ask either oracle have any small business application or not ? why should we buy se

  • Converting a roi to image

    I am trying to convert a ROI I got from Magic Wand to display as an image. I am able to get the mask but what I need is just an image of the ROI. Are you able to help?