Determining whether an integer is a floating-point number

I want to create a program that when an integer is input into the numeric constant, a floating-point number with all zeros to the right of its decimal point will light the LED on the front panel. The LED will remain unlit for any other floating-point number. I know I want to use a Round to Nearest function, but not sure where to go from there. 

rtufaro wrote:
I want to create a program that when an integer is input into the numeric constant,
You mean CONTROL, right?
You just need a type of rounding.  Doesn't matter if you round up or down.  So you just round and then compare the input to the rounded value.  If they are equal, you light up your LED.  So all you need is a numeric control, 2 functions, and a boolean indicator.

Similar Messages

  • How to restrict the decimal place of a floating point number?

    Hi,
    Here is my code:
    public void TwoDecimal(double u){
         String w = Double.toString(u);
         int c = w.length();
         System.out.println(c);
         if (c <= 5)
            double a = Double.parseDouble(w);
            System.out.println(a);
         else
            System.out.println("Invalid input!");
      }I want to show a floating point number which has 2 digits and 2 decimal places, e.g. 45.82, 29.67. This number is input by user and passed as a parameter.
    For those case like the above sample floating point numbers, it can display the proper value of 'c'. e.g. 45.67 will display 5.
    However, when I passed 99999, it will show 7; 9999 will return 6, not 5.
    So, if the user does not input the '.', does it append 2 implicit chars to it? i.e. 99999.0 and 9999.0. So, that's why it returned 7 and 6 for the length of the string respectively.
    How can I fix it?
    and
    Does it has better algorithm?
    Pls advise.
    gogo

    When dealing with a known precision, in your case hundredths, it is often a good idea to use an integer type and add in the decimals on printing only. This is often the case in banking systems. Almost all of them use integer types, (read long) in pennies to store monitary values. Ever seen someone type in a value for a credit card machine? For something like $20 they press.. "2" "0" "0" "0" The machine knows the lowest denomonation in a cent, so it knows where to put the decimal place. I suggest you do something like this. It also helps to avoid base 2 round off errors.
    -Spinoza

  • Maximum size of a floating-point number

    Morning all,
    Does anyone know what the maximum size of a floating point number can be under Solaris 8 running on
    a V880?
    Regards,
    Richard Breckon

    I'm not sure what you're asking.
    The maximum size is 128 bits.
    The maximum value is as given in /usr/include/float.h: 1.189731495357231765085759326628007016E+4932L

  • X64 Asm floating point number adressing .

    Dear Community
    Please kindly inform us about the number offloating-point
    addressing mode x64 Asm
    Best Regards
    Rafał Bator

    Hi RB_1,
    Your issue is out of support range of VS General Question forum which mainly discusses
    WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
    and Visual Studio Editor.
    You post the issue in this thread:
    https://social.msdn.microsoft.com/Forums/en-US/78825b09-d948-4676-a343-1791bad36603/asm-codnig-floating-point-number?forum=vcgeneral
    so I will remove this thread. Please discuss your issue on that thread or opening new thread on Visual C++ forum.
    Thanks,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • 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

  • Check Floating Point Number

    Hello All,
    I am having some trouble checking the value of a field with Key Figure type Number with 8 byte floating point. I want to read that field and populate another field with an X if true. For example if that field is equal to 5,0000000000000000E+07 then i want to mark the other field with an 'X'.
    The problem is in my code, how do i read that number in the fltp field, such as the number above. my code reads as follows for the 'X' field.
        if SOURCE_FIELDS-abc123 eq 5000000.
          RESULT = 'X'.
        endif.
    Thanks everyone in advance

    You don't need to worry about converting the code into standard format or floating, just implement your code as you want and it will automatically take care of the conversion. Basically 5,0000000000000000E+07 = 50,000,000.
    thanks.
    Wond

  • Floating point number using Modbus RTU DSC LV 8.2

    I'm reading temperature from a Modbus conrolled device. I need to convert a temperature value (17053) read as a double type Shared Variable (SV) and convert it to ieee 754 type to show temp of 79 deg F as shown on the control front panel.
    I'm using DSC module LV 8.2. I'm wondering if the conversion is already done in DSC LV 8.5???

    seem to find my own answers after putting the post....
    I use a typecast to single but I had to change the double to 16 bit integer for the type cast to convert correctly.... see attached png
    Attachments:
    ModbusSVFloat.PNG ‏28 KB

  • Exception with floating point number

    I get the following message if i try to import a floatingpoint number (12.12 is the number).
    oracle.xml.sql.OracleXMLSQLException: 'java.lang.NumberFormatException: 12.12' encountered during processing ROW element 0. All prior XML row changes were rolled back. in the XML document.
    I4ve tested anything with '.', ',' NLS-Parameters and so on.
    The Bugfix is now to multiply the number with 100. It4s not fine, but it works.
    Thanks in advance,
    Oliver Friedrich
    null

    Hello,
    this is a short piece of my code. I think there is all information you need.
    Greetings
    Oliver Friedrich
    String xmlControl = "CONTROL"; // XML tag
    String dbControl = "XML_CONTROL"; // Database table
    OracleXMLSave saveObject = new OracleXMLSave(conn, dbControl);
    saveObject.setRowTag(xmlControl);
    saveObject.setIgnoreCase(true);
    saveObject.setDateFormat("yyyyMMdd");
    int count = saveObject.insertXML((Document)docImport);
    XML-File:
    <?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
    <CONTROL>
    <NUMBER>12</NUMBER>
    <COST>123.45</COST>
    </CONTROL>
    </ROOT>
    Database-Table
    desc XML_CONTROL
    Column Name Null? Type
    NUMBER NUMBER(12)
    COST NOT NULL FLOAT(32)
    null

  • Floating point number to IBM bytes

    Hello,
    I'm trying to convert a float value to a byte array (but in IBM standard).
    I understand that the general idea will be the following algorithm:
    1. process the sign, exponent and fraction from the float value (using IBM standard)
    2. build the bytes from the S, E, F from step 1.
    So far, I only have the step 2 like this:
    public static byte[] toBytesIbm( int signBit, int exponent, long fraction ) {
    byte[] bytes = new byte[4];
    bytes[0] = (byte)(signBit + exponent);
    bytes[1] = (byte)((fraction & 0x00FF0000) >> 16);
    bytes[2] = (byte)((fraction & 0x0000FF00) >> 8);
    bytes[3] = (byte)(fraction & 0x000000FF);
    return bytes;
    Getting the sing bit is also not a problem, so the real work is in getting the exponent and fraction from the number. I don't know how to do this. I have code from a trusted source to convert from IBM bytes to IEEE float numbers, so I can check if the bytes are correct.
    Can anyone help me with this?
    Thanks in advance

    Brushfire wrote:
    Thanks for the correct. I'm never quite sure about the masks, but I've had issues with extra data being introduced before, so I like it better safe than sorry. The mask is needed when a narrower primitive has been sign-extended to a wider primitive, and you want to keep the result unsigned.
    But in this case, the result is then cast to byte, which removes all the upper bits that the mask was trying to set to zero in the first place.
    If you need to store a byte in an int without sign-extension, you need a mask:
    int n = someByte & 0xFF;If you want to store the lower 8 bits of an int in another int, you need a mask:
    int lowerEight = someInt & 0xFF;But if you want to store the lower 8 bits in a byte, just cast:
    byte lowerEight = (byte)someInt;

  • How to make floating point division

    I have tried many alternatives but i couldnt make any single floating point number printed to a page...
    I am compiling the servlet with eclipse 3.2 without any error but the jsp page says      java.lang.NoSuchFieldError: floatnumber even i have that variable...
    i have tried double,float but both of them makes the error above...but i can print long as well.
    can anyone teach me to divide 2 integer values and print the exact result like;
    3 / 5 = 0.6

    can anyone teach me to divide 2 integer values and
    print the exact result like;
    3 / 5 = 0.6
    int a= 3, b= 5;
    double result= ((double)a)/b;... or any valid variation thereof.
    kind regards,
    Jos

  • 128-bit floating point numbers on new AMD quad-core Barcelona?

    There's quite a lot of buzz over at Slashdot about the new AMD quad core chips, announced yesterday:
    http://hardware.slashdot.org/article.pl?sid=07/02/10/0554208
    Much of the excitement is over the "new vector math unit referred to as SSE128", which is integrated into each [?!?] core; Tom Yager, of Infoworld, talks about it here:
    Quad-core Opteron? Nope. Barcelona is the completely redesigned x86, and it’s brilliant
    Now here's my question - does anyone know what the inputs and the outputs of this coprocessor look like? Can it perform arithmetic [or, God forbid, trigonometric] operations [in hardware] on 128-bit quad precision floats? And, if so, will LabVIEW be adding support for it? [Compare here versus here.]
    I found a little bit of marketing-speak blather at AMD about "SSE 128" in this old PDF Powerpoint-ish presentation, from June of 2006:
    http://www.amd.com/us-en/assets/content_type/DownloadableAssets/PhilHesterAMDAnalystDayV2.pdf
    WARNING: PDF DOCUMENT
    Page 13: "Dual 128-bit SSE dataflow, Dual 128-bit loads per cycle"
    Page 14: "128-bit SSE and 128-bit Loads, 128b FADD, 128 bit FMUL, 128b SSE, 128b SSE"
    etc etc etc
    While it's largely just gibberish to me, "FADD" looks like what might be a "floating point adder", and "FMUL" could be a "floating point multiplier", and God forbid that the two "SSE" units might be capable of computing some 128-bit cosines. But I don't know whether that old paper is even applicable to the chip that was released yesterday, and I'm just guessing as to what these things might mean anyway.
    Other than that, though, AMD's main website is strangely quiet about the Barcelona announcement. [Memo to AMD marketing - if you've just released the greatest thing since sliced bread, then you need to publicize the fact that you've just released the greatest thing since sliced bread...]

    I posted a query over at the AMD forums, and here's what I was told.
    I had hoped that e.g. "128b FADD" would be able to do something like the following:
    /* "quad" is a hypothetical 128-bit quad precision  */
    /* floating point number, similar to "long double"  */
    /* in recent versions of C++:                       */
    quad x, y, z;
    x = 1.000000000000000000000000000001;
    y = 1.000000000000000000000000000001;
    /* the hope was that "128b FADD" could perform the  */
    /* following 128-bit addition in hardware:          */
    z = x + y;
    However, the answer I'm getting is that "128b FADD" is just a set of two 64-bit adders running in parallel, which are capable of adding two vectors of 64-bit doubles more or less simultaneously:
    double x[2], y[2], z[2];
    x[0] = 1.000000000000000000000000000001;
    y[0] = 1.000000000000000000000000000001;
    x[1] = 2.000000000000000000000000000222;
    y[1] = 2.000000000000000000000000000222;
    /* Apparently the coordinates of the two "vectors" x & y       */
    /* can be sent to "128b FADD" in parallel, and the following   */
    /* two summations can be computed more or less simultaneously: */
    z[0] = x[0] + y[0];
    z[1] = x[1] + y[1];
    Thus e.g. "128b FADD", working in concert with "128b FMUL", will be able to [more or less] halve the amount of time it takes to compute a dot product of vectors whose coordinates are 64-bit doubles.
    So this "128-bit" circuitry is great if you're doing lots of linear algebra with 64-bit doubles, but it doesn't appear to offer anything in the way of greater precision for people who are interested in precision-sensitive calculations.
    By the way, if you're at all interested in questions of precision sensitivity & round-off error, I'd highly recommend Prof Kahan's page at Cal-Berzerkeley:
    http://www.cs.berkeley.edu/~wkahan/
    PDF DOCUMENT: How JAVA's Floating-Point Hurts Everyone Everywhere
    http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf
    PDF DOCUMENT: Matlab's Loss is Nobody's Gain
    http://www.cs.berkeley.edu/~wkahan/MxMulEps.pdf

  • Precision operation (Float point) on FPGA 2011

    Dear Experts....
    For my application I have to perform demodulation operation on FPGA. I want to store an array of double precision number. When I am trying to perform any double precision number operation I am getting this error "Wire:Type not supported in current target" From forums I came to know that on FPGA  in Labview 2011 I cannot have double precision operation. What is alternative?? Please help me with this. Due to this issue my work has been delayed due to this problem..
    Thanks... Kindly guide...
    Solved!
    Go to Solution.

    Dear Mathan, thanks for your reply.... I have already gone throught the link you sent, but for my application I have to have array of floating points number. I can not have integer numbers. Here I have attached my vi. I have to mix a signal of 20 Mhz with sin and cos signal to achieve demodulation. So for Sin and Cos values I have to have floating point. Is ther any way to overcome this problem?
    Attachments:
    fpga.vi ‏30 KB

  • How to scale 32-bit signed integer data to floating-p​oint voltage when acquring data in DAQmx by PXI4472?

    I acquired data in DAQmx by PXI4472. For the high speed data logger, I used "DAQmx Read" to read unscaled 32-bit signed integer data.
    Now, my question is how to scale 32-bit signed integer data to floating-point voltage?
    I think that it's (20/(2**24))*I32 because the voltage range of PXI4472 is -10 to +10 and its resolution is 24 bits. But I cann't get correct voltage by that formula.

    While you could hard code the scaling factor, it will be more flexible if you retrieve the scaling coefficients from the driver. To do this, you need to use the Analog Input>>General Properties>>Advanced>>Device Scaling Coefficients>>Device Scaling Coefficients properties under the DAQmx Channel Property Node. Look at the documentation for this property to see how it can be used to create a polynomial equation for scaling to volts.
    Since you are creating a data logging solution, you may want to consider using a compressed data stream from the driver instead of the I32 data type. This will allow you to read the data back as a stream of u8's instead. Since the PXI-4472 is 24 bits, you will only have to write 3 bytes to disk for each sample instead of 4. You can check out the following examples for how to create an application using this compressed data stream. It also shows how to use the scaling coefficients to transform the unscaled data back to voltage values.

  • Floating point to integral type

    could anybody please explain how "round toward zero" works?
    or any documentation on this.
    thanks.

    If you want the simple answer, it rounds towards zero - that is for any floating point number, rounding will give the nearest integer value closets to 0. So 234.1 ->234.0, while -234.1 -> -234.0.
    This is as opposed towards other conventions such as rounding towatds +/- infinity
    If you want to blow your brains out trying to really undewrstand this, try this

  • Floating Point Representations on SPARC (64-bit architecture)

    Hi Reader,
    I got hold of "Numerical Computation Guide -2005" by Sun while looking for Floating Point representations on 64 bit Architectures. It gives me nice illustrations of Single and Double formats and the solution for endianness with
    two 32-bit words. But it doesn't tell me how it is for 64-bit SPARC or 64-bit x86.
    I might be wrong here, but having all integers and pointers of 64-bit length, do we still need to break the floating point numbers and store them in lower / higher order addresses ??
    or is it as simple as having a Double Format consistent in the bit-pattern across all the architectures (Intel, SPARC, IBMpowerPC, AMD) with 1 + 11 + 52 bit pattern.
    I have tried hard to get hold of a documentation that explains a 64-bit architecture representation of a Floating Point Number. Any suggestion should be very helpful.
    Thanks for reading. Hope you have something useful to write back.
    Regards,
    Regmee

    The representation of floating-point numbers is specified by IEEE standard 754. This standard contains the specifications for single-precision (32-bit), and double-precision (64-bit) floating-point numbers (There is also a quad-precision (128-bit) format as well). OpenSPARC T1 supports both single and double precision numbers, and can support quad-precision numbers through emulation (not in hardware). The fact that this is a 64-bit machine does not affect how the numbers are stored in memory.
    The only thing that affects how the numbers are stored in memory is endianness. SPARC architecture is big-endian, while x86 is little-endian. But a double-precision floating-point numer in a SPARC register looks the same as a double-precision floating-point number in an x86 register.
    formalGuy

Maybe you are looking for

  • Can no longer add music files to itunes after 10.4 update

    For over 7 years i have used frostwire to download and save music into a m3u file on my computer. Then i would go to itunes and add file to library locate my file i would call my music and add it. Never have i had a problem however after the 10.4 upd

  • Converting lines to fills

    A client of mine has all these product logos that have a thick 10-point outline around the text. When I import these logos into Flash I always want to convert the outline to a fill, because otherwise when I use alpha to fade the logo in and out durin

  • TS1702 iPad iTunes and app store closes

    I have a iPad 1 and iTunes and app store closes after 5 min of use. Have closed all apps. Powered off and performed reset updates are current . Need help please

  • Opening a new window from navigation bar?

    I want one of my navigation bar links to open in a new window. There doesn't seem to be a place where i can specify the target="_blank" attribute so I've tried using javascript. If I enter: "javascript:window.open('URL HERE', 'WINDOW NAME HERE', 'loc

  • Maximum number of Kinect for Windows v2 Cameras on one PC?

    There is a question about the previous iteration of the Microsoft Kinect for Windows (no longer on sale) here: https://social.msdn.microsoft.com/Forums/en-US/63c7c52e-1290-452e-8e04-74330822d16f/maximum-number-of-kinect-cameras-on-one-pc?forum=kinect