Converting binary to floating point?

ok, i am programming a little java program at the consulter
the main idea of the program is to convert a decimal number to IEEE (floating point)
i am almost done except the exponent part
i dont understand the logic behind it
so, for example:
-6.625 = 110.101 (binary)
after normalization it will be -1.10101 * 2^2
so the IEEE will be
1 10000001 10101000000000000000000
i understand the sign part and the fraction part
but i have no idea how the exponent part came like this
the book say that 129-127=+2 so the exponent is 10000001
da, where it came from ???
i will appreciate it if someone explain this part for me step by step
thank you,
Edited by: abdoh2010 on Jan 26, 2008 2:37 AM

got it
thank you for viewing my question

Similar Messages

  • Convert string to floating-point

    Hi all,
    ..very basic question, but I tryed it for hours and only received short-dumps
    <b>How can I convert a string into a floating-point number?</b>
    Kind regards,
    Stefan

    hi
    try this
    to convert  string to float.
    data : a type f,
    s type string value '1.023'.
    a = s.
    write :/ a.
    to convert float to string.
    data : a type f value '1.023',
    s type string.
    s = a.
    write : s.

  • Right justification of floating point values

    Hi all
    i need to convert a incoming floating point value  into (8.2) format i.e. (33678.9956 into    33678.99) i.e. spaces should be padded before if number of digits before decimal is less than 8 and i need to right justify all the incoming values..
    pls help me in doing that through graphical mapping.

    Hi Barry,
    sorry, the format given in the previous post is incorrect...
    the required  format is just opposite to that..i.e. all DOTS in the same column.
    hope my requirement is clear..
    Regards,
    Manohar

  • Using Floating Point

    I write mobile java program using float point operations
    but i instal to the mobile as a jar file
    the mobile refuse that and give a message: "No supported floating point"
    so what the solution for this problem

    Recently I have to do a project where the main task is to port a J2SE application to J2ME. The J2SE application was full of floating point operation and as per my knowledge J2ME does not support floationg point operation due to low memory availability. So I have converted all the floating point operations to fixed point. I found no other way to execute floating point operations :-(

  • Converting 32bit binary to float

    hi again,
    is there a simple method for converting a string representation of a 32-bit binary value into its corresponding floating point value?
    e.g. string s = "01000001110011100001010001111011"
    thanks in advance

    Or, do you mean the 32 bit number represents a float. The following displays 25.76.
    String s="01000001110011100001010001111011";
    int v=Integer.parseInt(s,2);
    float f=Float.intBitsToFloat(v);
    System.out.println(f);

  • BUG: Large floating point numbers convert to the wrong integer

    Hi,
    When using the conversion "bullets" to convert SGL, DBL and EXT to integers there are some values which convert wrong. One example is the integer 9223370937343148030, which can be represented exactly as a SGL (and thus exactly as DBL and EXT as well). If you convert this to I64 you get 9223370937343148032 instead, even though the correct integer is within the range of an I64. There are many similar cases, all (I've noticed) within the large end of the ranges.
    This has nothing to do with which integers can be represented exactly as a floating point value or not. This is a genuine conversion bug mind you.
    Cheers,
    Steen
    CLA, CTA, CLED & LabVIEW Champion
    Solved!
    Go to Solution.

    Yes, I understand the implications involved, and there definetely is a limit to how many significant digits that can be displayed in the numeric controls and constants today. I think that either this limit should be lifted or a cap should be put onto the configuration page when setting the display format.
    I ran into this problem as I'm developing a new toolset that lets you convert all the numeric formats into any other numeric format, just like the current "conversion bullets". My conversion bullets have outputs for overflow and exact conversion as well, since I need that functionality myself for a Math toolset (GPMath) I'm also developing. Eventually I'll maybe include underflow as well, but for now just those two outputs are available. Example:
    I do of course pay close attention to the binary representation of the numbers to calculate the Exact conversion? output correctly for each conversion variation (there are hundreds of VIs in polymorphic wrappers), but I relied in some cases on the ability of the numeric indicator to show a true number when configured appropriately - that was when I discovered this bug, which I at first mistook for a conversion error in LabVIEW.
    Is there a compliancy issue with EXT?
    While doing this work I've discovered that the EXT format is somewhat misleadingly labelled as "80-bit IEEE compliant" (it says so here), but that statement should be read with some suspicion IMO. The LabVIEW EXT is not simply IEEE 754-1985 compliant anyways, as that format would imply the x87 80-bit extended format. An x87 IEEE 754 extended precision float only has 63-bit fraction and a 1-bit integer part. That 1-bit integer part is implicit in single and double precision IEEE 754 numbers, but it is explicit in x87 extended precision numbers. LabVIEW EXT seems to have an implicit integer part and 64-bit fraction, thus not straight IEEE 754 compliant. Instead I'd say that the LabVIEW EXT is an IEEE 754r extended format, but still a proprietary one that should deserve a bit more detail in the available documentation. Since it's mentioned several places in the LabVIEW documentation that the EXT is platform independent, your suspicion should already be high though. It didn't take me many minutes to verify the apparent format of the EXT in any case, so no real problem here.
    Is there a genuine conversion error from EXT to U64?
    The integer 18446744073709549568 can be represented exactly as EXT using this binary representation (mind you that the numeric indicators won't display the value correctly, but instead show 18446744073709549600):
    EXT-exponent: 0x100000000111110b
    EXT-fraction: 0x1111111111111111111111111111111111111111111111111111000000000000b
    --> Decimal: 18446744073709549568
    The above EXT value converts exactly to U64 using the To Unsigned Quad Integer "bullet". But then let's try to flip the blue bit from 0 to 1 in the fraction part of the EXT, making this value:
    EXT-exponent: 0x100000000111110b
    EXT-fraction: 0x1111111111111111111111111111111111111111111111111111100000000000b
    --> Decimal: 18446744073709550592
    The above EXT value is still within U64 range, but the To Unsigned Quad Integer "bullet" converts it to U64_max which is 18446744073709551615. Unless I've missed something this must be a genuine conversion error from EXT to U64?
    /Steen
    CLA, CTA, CLED & LabVIEW Champion

  • Floating point to binary conversion

    Hi
    I need to convert a floating point decimal number to bits.
    Eg. 0.000532 to be converted to binary(bits).
    How do I do this?

    Now if I convert that decimal number to bits(in
    the usual method of dividing by 2),will that be the
    exact binary representation of the floating point
    decimal number?You have the same bit pattern in both cases. In one it's held in a double and will be interpreted as a floating point number according to the IEEE 754 representation. In the other it's held in a long and will be interpreted according to the two's complement representation. But it's the same bitpattern.
    Note that Long has a toString method which allows you to convert the long to a String. The radix in your case is 2 for binary.

  • Profibus data type converting to floating point

    Hi, 
    Is there an efficient way to convert  the incoming data to the floating point in the NI cRIO Profibus system? 
    1) The system is : NI cRIO 9068 Controller with Comsoft profibus slave module. The lavview we are using is 2013. 
    2) We are using profibus slave example and are able to see a array of unsigned 8 bit data. Please see the Output data shown in the attachement.
    3) On the other side of profibus system, thrid party profibus master are converting floating points and tranmit the converted data to NI profibus slave. 
    Attachments:
    Screenshoot.png ‏7 KB

    If it's just a matter of converting data types once you have the data in LabVIEW, you can always manually scale and convert the data using the arithmetic functions and the "To Double Precision Float" or "To Single Precision Float" functions. You just have to know what floating point value the unsigned byte integer corresponds to. Is that what you're asking?
    If you're asking for a way to this inherently with the Profibus functions, I'm afraid I can't be of much help...
    Ryan K.

  • How to read binary floating point values from TCP/IP

    I am attempting to use a LabView application to read an array of binary single precision floating point numbers transferred through a TCP/IP connection from a Windows C++ program. The endianization occurs before the values are sent to the Labview application. When I read the values in LabView, some values are interpreted correctly, some are not. For instance, the C program is sending a 6 as one element, and 7 as another. Labview interprets both as 6. The difference between 6 and 7 in binary format is 1 bit (bit #21 if counting from 0 in LabView format). There are 2 other values that show the same error- 459.67 is being sent, 395.67 is read by labview (1 bit difference, exact same bit... 7.5 is being sent, 6.5 is being read by LabView (1 bit difference, exact same bit). LabView reads that bit as 0, when it should be 1.
    This seems very odd to me because most values are being read correctly, including other values with that same bit on. There are values being read correctly that are both before and after the incorrect values in the array, so it's not just an issue with an offset or something in the bit stream. Additionally, when attempting to read an array of values with all bits on, I get a strange pattern of 111110011111100111111001111110.
    We have also verified that the binary representation for the values is the same on both machines, once you account for the byte swapping. What am I missing here? How in the world can some values come across correctly and others incorrectly? Any help would be greatly appreciated! Our fallback is to transfer everything in ASCII, which is going to greatly increase packet sizes.
    Thanks,
    Jason

    Update:
    Problem fixed. I say fixed and not solved because I don't know why it's fixed. I had been storing the TCP/IP read in a string and passing it through a shift register after each read. I would then concatenate it with the TCP/IP read result in the next loop. After each read, it would search the concatenated string for ASCII flags. When it found them, it would strip off the flags and then type cast the rest as single precision floating points.
    I knew I would be getting the same number of bytes each time, so I ditched the ASCII flags and had just the binary values sent. This way, I expect to get all of the values in one TCP/IP read. No values are passed through a shift register to the next loop and there is no concatenation of the string outputs from TCP/IP read.
    I'm not sure if it was the ASCII flags being included or something with the way I was manipulating the string that was causing the binary values to be interpreted incorrectly. Hope this helps someone else.
    Jason

  • Convertion Hex String to 32bits Decimal floating point??

    Hi,
    I would like to know how to convert hexa like: 416b0ac3 in decimal 32bits floating-point. The result of this string is suppose to be 14.690127.
    So i must be able to do:
    From 32-bit Hexadecimal Representation To Decimal Floating-Point
    Thanks for your support
    RiderMerlin

    RiderMerlin
    You can use the typecast function to do this.
    David
    Message Edited by David Crawford on 09-06-2006 03:31 PM
    Attachments:
    Typecast to Single.jpg ‏6 KB

  • Convert Floating Point Decimal to Hex

    In my application I make some calculations using floating point format DBL,and need to write these values to a file in IEEE 754 Floating Point Hex format. Is there any way to do this using LabVIEW?

    Mike,
    Good news. LabVIEW has a function that does exactly what you want. It is well hidden though...
    In the Advanced/Data manipulation palette there is a function called Flatten to String. If you feed this funtion with your DBL precision digital value you get the IEEE-754 hexadecimal floating point representation (64 bit) at the data string terminal (as a text string).
    I attached a simple example that shows how it works.
    Hope this helps. /Mikael Garcia
    Attachments:
    ieee754converter.vi ‏10 KB

  • Converting Floating Point

    I am receiving numbers from a Tinius Olsen Model 290 Universal Testing System.  I made a little program to send commands to the machine and receive the responses back as strings.  For the decimal value 3.7620 I get the floating point number EDC57040.  This is obviously not correct.  The correct floating point representation is 4070C5ED, which is accomplished by swapping all the bits.  I need to know how to do this in labview, basically go from the string representation of the floating point to the correct swapped floating point.

    Here is a simple example:
    Be aware that if you have an ancient version of LabVIEW, this option (byte order) is not available and you need to swap the bytes manually. No big deal, really.
    Message Edited by altenbach on 05-08-2007 01:15 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    LittleEndianSGL.png ‏7 KB

  • Precision loss - conversions between exact values and floating point values

    Hi!
    I read this in your SQL Reference manual, but I don't quite get it.
    Conversions between exact numeric values (TT_TINYINT, TT_SMALLINT, TT_INTEGER, TT_BIGINT, NUMBER) and floating-point values (BINARY_FLOAT, BINARY_DOUBLE) can be inexact because the exact numeric values use decimal precision whereas the floating-point numbers use binary precision.
    Could you please give two examples: one where a TT_TINYINT is converted to a BINARY_DOUBLE and one when a TT_BIGINT is converted into a DOUBLE, both cases give examples on lost precision? This would be very helpful.
    Thanks!
    Sune

    chokpa wrote:
    Public Example (float... values){}
    new Example (1, 1e2, 3.0, 4.754);It accepts it if I just use 1,2,3,4 as the values being passed in, but doesn't like it if I use actual float values.Those are double literals, try
    new Example (1f, 1e2f, 3.0f, 4.754f);

  • Floating point Number & Packed Number

    Hai can anyone tell me what is the difference in using floating point & packed Number .
    when it will b used ?

    <b>Packed numbers</b> - type P
    Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.
    You can use type P data for such values as distances, weights, amounts of money, and so on.
    <b>Floating point numbers</b> - type F
    The value range of type F numbers is 1x10*-307 to 1x10*308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the floating point arithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.
    You use type F fields when you need to cope with very large value ranges and rounding errors are not critical.
    Using I and F fields for calculations is quicker than using P fields. Arithmetic operations using I and F fields are very similar to the actual machine code operations, while P fields require more support from the software. Nevertheless, you have to use type P data to meet accuracy or value range requirements.
    reward if useful

  • IEEE Floating point format converstion to ForteDouble

    Question:
    Given that I have 4 bytes of binary data which represents a number in
    IEEE floating point format,
    and I wish to convert it to a Forte DoubleData, will the following code
    give me the correct answer
    in Value?
    (Assume that file is correctly set up, etc...)
    Value : DoubleData = new;
    FPoint : point to float;
    F : float;
    LineText : BinaryData = new;
    File.ReadBinary(LineText,4);
    Fpoint = (pointer to Float)(LineText.Value);
    F = *Fpoint;
    Value.SetValue(F);
    Thanks
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Mark,
    you might try testing whether forte floats are IEEE in the following
    way using the following:
    pflt : pointer to float = (pointer to float) (res.value);
    flt = *pFlt;
    however, I believe you will have to wrapper a C function to do this.
    The C function takes a void * first argument and has a float
    void ConvIEEE(void * buffer, float * return)
    return = (float) (buffer);
    or
    void ConvIEEE(void buffer, float return)
    ieeefloat ie;
    ie = (ieeefloat) (*buffer);
    *return = IEEELibraryConvertToFloat(ie);
    depending upon whether C floats are IEEE or not on your
    platform/compiler. I think you'll have to investigate this yourself,
    or try the first approach and see if it works.
    Good luck!
    assuming, of course, that your C compiler's float is also IEEE format.
    Your forte wrapper would look like
    class floatWrapper inherits from framework.object
    has public method ConvIEEE(input buffer : pointer,
    output return : float)
    end class;
    with your binarydata you would
    res : binarydata = (get from somewhere)
    flt : float;
    fw : FloatWrapper = new;
    fw.ConvIEEE(res.value,flt);
    Mark Sundsten wrote:
    >
    Question:
    Given that I have 4 bytes of binary data which represents a number in
    IEEE floating point format,
    and I wish to convert it to a Forte DoubleData, will the following code
    give me the correct answer
    in Value?
    (Assume that file is correctly set up, etc...)
    Value : DoubleData = new;
    FPoint : point to float;
    F : float;
    LineText : BinaryData = new;
    File.ReadBinary(LineText,4);
    Fpoint = (pointer to Float)(LineText.Value);
    F = *Fpoint;
    Value.SetValue(F);
    Thanks
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>--
    John Jamison [email protected]
    Vice President and Chief Technology Officer
    Sage IT Partners, Inc.
    Voice: 415 392-7243 x 306
    Fax: 415 391-3899
    Internet Enabled Business Change
    http://www.sageit.com
    -----------------------------------------------------

Maybe you are looking for

  • Error when scheduling infopackage for PA_PA OEMPLOYEE

    hi all, when iam scheduling info package for OEMPLOYEE it is giving error like "0EMPLOYEE : Overlapping time intervals of data record 298 with 305 : '['20040831'/'20040324'] '[to/from]     RSDMD 190 ". iam unable to solve it.please help me in this is

  • Down Payment for Investment Measure

    Dear experts, I want to use down payment against an Investment measure (i.e. Internal Order for capital items). My scenario is as follows: We have the following need for payments: 30% down payment 60% on goods receipt 10% on acceptance of the capital

  • Generating web PL/SQL Form header (MODSHD) including modulename

    Hi all, I want to generate a WEB PL/SQL form using a template. The call to the stored function goes fine. I call package.function which returns a string, that is displayed. So far so good... However, I want to display the name of the Module (or some

  • How do I save passwords; the dialog box has no yes option

    Whenever I fill in a user name then fill in a password, the dialog box appears asking if I want to save the password. There is a drop down box offering two options, to save or not to save. I choose to save which is in fact the default. However, there

  • Importing from Flickr

    I have Adobe Elements 11 and want to download or import some photos FROM Flickr to Adobe. All of the help screens have it going the other way - exporting to Flickr. Can I do it and how?