Exponential to fixed point number convert

Hello All,
I am getting below result for the double value.
double d = 7777777.77;
System.out.println(d); O/P >> 7777777.77
double d1 = 88888888.88;
System.out.println(d1); O/P >> 8.888888888E7
Actually I dont want the value to be in Exponential format. I found that when the decimal is before 7 digits , am getting correct value (without exponential format). But when decimal is after 7 digits then value gets in exponential format.
If this is the default behaviour which we cant change then how to convert the exponential format number to fixed point number.
Thanks
Prasad.

Don't use the default conversion on double numbers except for debugging. Convert floating point numbers to String format either with String.format, or with a DecimalFormat object. Either gives you proper control over the format.

Similar Messages

  • Issue with fixed point number output from 9219 module for full bridge measurement (cRIO/FPGA)

    Hi,
    I have a question regarding the fixed point output acquired from a 9219 module (in FPGA on a cRIO) when setup to acquire a strain measurement (full bridge).
    Software: Labview 2009
    Hardware: cRIO-9012 (NI-RIO 3.2.1), NI-9219 module
    The 9219 module is configured in the project as follow:
    Ch0: Full-Bridge +/- 7.8mV/V
    Ch1: Voltage +/- 4V
    Ch2: Voltage +/- 15V
    Ch3: Voltage +/- 60V
    The calibration mode is 'Calibrated' so the FPGA outputs fixed point numbers. 
    My issue is that the precision of the fixed point number for Ch0 (strain) is "(fixed point <+/-32,-1>[-2.5e1,2.5e1]:1.16e-10)", which indicates that the fixed point number is a value between +/- 0.25 and not the +7.8mV/V as I expected?
    The fixed point number does not change in precision whether the range for the strain measurement is set at +/- 7.8mV/V or +/-64mV/V (the two available options).
    As the fixed point number doesn't change precision I'm assuming that changing the range of the strain measurement changes the resolution of the acquired number? And as such I will need to perform additional scaling on the fixed point number to convert it to the expected range?
    There is no mention of scaling of the voltage or strain measurements mentioned in any documentation or examples, with the only scaling example provided for the thermocouple measurements.
    Any help/clarification is much appreciated.
    Regards,
    Mike

    Hello Mike,
    Hopefully I can help clarify some of the behavior you are seeing.
    My issue is that the precision of the fixed point number for Ch0 (strain) is "(fixed point <+/-32,-1>[-2.5e1,2.5e1]:1.16e-10)", which indicates that the fixed point number is a value between +/- 0.25 and not the +7.8mV/V as I expected?
    For calibrated values on the FPGA VI, the returned data is a Voltage measurement, not a directly calculated strain value. Based on the specified ranges for the 9219 in a Full bridge configuration, 250 mV will encompass all possible input values, at the module provided excitation (2-2.7V dependent on the sensor gage resistance).
    The fixed point number does not change in precision whether the range for the strain measurement is set at +/- 7.8mV/V or +/-64mV/V (the two available options).
    As you may notice from the fix-point definition, the fixed point data contains 32-bit precision which is larger than the acquired precision of 24-bits provided by the 9219. The fixed point data-type is coded to accept input encompassing both the range and precision of the instrument; such that, no additional coercion of the input data values is required based on user-defined software settings, i.e. the bridge sensitivities +/- 7.8mV/V or +/-64mV/V. 
    As the fixed point number doesn't change precision I'm assuming that changing the range of the strain measurement changes the resolution of the acquired number? And as such I will need to perform additional scaling on the fixed point number to convert it to the expected range?
    The documentation does not clearly define that by varying the discrete levels of strain input (+/- 7.8mV/V or +/-64mV/V) the range of the ADC on the module is also adjusted. I am working to follow up further on this topic, to provide a clarification on the module documentation. As for scaling, the voltage values acquired regardless of the ADC resolution will still be related strain via the bridge sensitivity. The resolution of the ADC will simply define the smallest measurable change in the strain value. 
    There is no mention of scaling of the voltage or strain measurements mentioned in any documentation or examples, with the only scaling example provided for the thermocouple measurements.
    For converting the acquired voltage values to a strain measurement, I would recommend the documentation linked here for a detailed explanation on strain calculation. Often, users will forward the acquired voltage data as fixed point values through a DMA FIFO to the RT controller on the Compact RIO; such that, they may handle conversion from voltage to strain using floating point math in real-time. 
    I hopes these responses provided a bit of clarity. I will continue to work to provide additional information on the 9219 specification information. Please post back any further questions.
    Cheers!
     Edit: Forgot to add the link.
    Message Edited by Pcorcs on 04-14-2010 04:55 PM
    Patrick Corcoran
    Application Engineering Specialist | Control
    National Instruments

  • IHow to force display of trailing zeros for fixed point numbers?

    I have an 8 bit unsigned fixed point number, with 7 integer bits and 1 fractional bit, so the desired delta is 0.5. I want it to always display the fractional bit, even when that bit is 0. In other words, as this number is incremented, I want to see:
    0.0
    0.5
    1.0
    1.5
    etc.
    But instead I'm seeing:
    0
    0.5
    1
    1.5
    etc.
    I set the display format to Floating point, with 1 digit of precision. The "Hide trailing zeros" checkbox is NOT checked. What am I doing wrong?
    I realize I could convert to single precision for display purposes to make this happen, but I'd rather make this work with fixed point.
    Thanks,
    -Ron

    I just rustled up a VI with what I understand your input to be - unsigned 7 bit mantissa and 1 bit exponent input, and have it displaying 2 decimal places.... Is this what you're after or did I miss it?
    - Cheers, Ed
    Attachments:
    zeros.vi ‏7 KB

  • 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

  • How do I find all the fixed points of a...

    How do I find the number of fixed points in a randomly increasing sequence of integers in O(log n) time?
    (1 1 1 1 5 7) as input will return 1. Because 5 is the fifth element.

    Consider this example instead of the erroneous example given above.
    Input: {-1, 0, 2, 4, 5, 6, 7}
    Output: 4
    I need an algorithm to find the number of fixed points of an increasing sequence in O(log n) time.
    Yes. The sequence is known beforehand.
    I was considering something like a binary search, but it would take more than O(log n) to find the number of fixed points.
    So currently I am thinking of using something like an averaging scheme, but I haven't found any solution yet.

  • Displayin message and fixing the number of rows in a table

    Hi Experts,
    I have a requirement like this
    there is a table, where i need to diplay a message when there are no records and no rows should be visible on that table.
    Also, when the records are populated from the context, i need to fix the number of rows in that table and display the records.
    Please let me know hw this can be achieved.
    Also in the table I have Link to URL, please let me know how to handle this reference, when i set the reference Property, its giving me an error stating that the file doesn't exist when the table gets loaded.
    Thanks in Advance
    Regards,
    Palani

    Hi
    Oh!!  You should to  explain it at first thread itself that you want to display a JPG imange or other WDWebResourceTypetaken form the backend.
    1. So this is not at all a URL
    2. You have to convert binary data to WDWebResource then display it in either Image UI element or other (like PDF , txt etc)
    3
    try
                   //        Read the datasource of the FileUpload
                   IWDResource res = wdContext.currentContextElement().getResource();
                   InputStream in = res.read(false);
                   ByteArrayOutputStream bOut = new ByteArrayOutputStream();
                   int length;
                   byte[] part = new byte[10 * 1024];
                   while ((length = in.read(part)) != -1)
                        bOut.write(part, 0, length);
                   in.close();
                   bOut.close();
                   IPrivateUploadCompView.IImageTableElement ele = wdContext.nodeImageTable().createImageTableElement();
                   ele.setImage(wdContext.currentContextElement().getResource().getUrl(0));
                   ele.setText(res.getResourceName());
                   wdContext.nodeImageTable().addElement(ele);
              catch (Exception e)
                   wdComponentAPI.getMessageManager().reportWarning(e.toString());
    Here I assume that you convert that data to IWDResource type or
    4.
    WDWebResource.getWebResource(wdContext.currentContextElement().getresource(), type);
    // getResource of type binary which u read from BAPI and set it in local context , type is MIMETYPE or hardcode it as "JPG"
    5. Further help
       [Help1|To Displayan Image in Webdynpro Java from Standard Function Module;
    [Help2|http://wiki.sdn.sap.com/wiki/display/KMC/GettinganimagefromKMDocumentstobeusedinWeb+Dynpro]
    [Help3|http://wiki.sdn.sap.com/wiki/display/KMC/GettinganimagefromKMDocumenttobeusedinWeb+DynPro]
    It might code look strange at first , please do some reserch in SDN ,I did my best at this level.
    Best Regards
    Satish Kumar

  • In need of Fixed-point algorithm

    hi peeps,
    Im in need ( a very urgent need ) of a fix-point algorithm , with explanations if possible. Can anybody point me to the right direction?
    thanks....

    See if this helps you,
    To find a solution to p=g(p)given an initial approximation p0.
    Input: Initial approximation p0; tolerance TOL; maximum number of
         iterations N0.
    Output: Approximate solution p or message of failure.
    Step 1: Set i=1;
    Step 2: While i<=N0 do Steps 3-6.
    Step 3: Set p=g(p0). (Compute p.)
    Step 4: If |p-p0| < TOL then
    OUTPUT (p); (Procedure completed successfully.)
    STOP.
    Step 5: Set i=i+1.
    Step 6: Set p0=p. (Update p0.)
    Step 7: OUTPUT('Method failed after N0 iterations, N0=', N0);
    (procedure completed unsuccessfully.)
    STOP.
    Fixed-Point Iteration Code in C Language
    * Fixed-Point Iteration Code in C Language
    * To find a solution to p = g(p) given an
    * initial approximation p0
    * INPUT: initial approximation; tolerance TOL;
    * maximum number of iterations NO.
    * OUTPUT: approximate solution p or
    * a message that the method fails.
    #include<stdio.h>
    #include<math.h>
    #define true 1
    #define false 0
    main()
    double TOL,P0,P;
    int I,NO,FLAG,OK;
    FILE *OUP[1];
    void INPUT(int *, double *, double *, int *);
    void OUTPUT(FILE **, int *);
    double absval(double);
    double G(double );
    INPUT(&OK, &P0, &TOL, &NO);
    if (OK)
    OUTPUT(OUP, &FLAG);
    /* STEP 1 */
    I = 1; OK = true;
    /* STEP 2 */
    while((I<=NO) && OK)
    /* STEP 3 */
    /* compute P(I) */
    P = G(P0);
    if (FLAG == 2)
    fprintf(*OUP, "%3d %15.8e\n", I, P);
    /* STEP 4 */
    if (absval(P-P0) < TOL)
    /* procedure completed successfully */
    fprintf(*OUP, "\nApproximate solution P = %12.8f\n", P);
    fprintf(*OUP, "Number of iterations = %3d", I);
    fprintf(*OUP, " Tolerance = %14.8e\n",TOL);
    OK = false;
    else
    /* STEP 5 */
    I++;
    /* STEP 6 */
    /* update P0 */
    P0 = P;
    if (OK)
    /* STEP 7 */
    /* procedure completed unsuccessfully */
    fprintf(*OUP, "\nIteration number %3d", NO);
    fprintf(*OUP, " gave approximation %12.8f\n", P);
    fprintf(*OUP, "not within tolerance %14.8e\n",TOL);
    fclose(*OUP);
    /* Change function G for a new problem */
    double G(double X)
    double g;
    g = sqrt(10.0 / (4.0 + X));
    return g;
    void INPUT(int OK, double P0, double TOL, int NO)
    char AA;
    printf("This is the Fixed-Point Method.\n");
    printf("Has the function G been created in the program immediately preceding\n");
    printf("the INPUT function?\n");
    printf("Enter Y or N\n");
    scanf("%c",&AA);
    if ((AA == 'Y') || (AA == 'y'))
    *OK = false;
    printf("Input initial approximation\n");
    scanf("%lf",P0);
    while(!(*OK))
    printf("Input tolerance\n");
    scanf("%lf", TOL);
    if (*TOL <= 0.0)
    printf("Tolerance must be positive\n");
    else
    *OK = true;
    *OK = false;
    while (!(*OK))
    printf("Input maximum number of iterations - no decimal point\n");
    scanf("%d", NO);
    if (*NO <= 0)
    printf("Must be positive integer\n");
    else
    *OK = true;
    else
    printf("The program will end so that the function G can be created\n");
    *OK = false;
    void OUTPUT(FILE **OUP, int *FLAG)
    char NAME[30];
    printf("Select output destination\n");
    printf("1. Screen\n");
    printf("2. Text file\n");
    printf("Enter 1 or 2\n");
    scanf("%d", FLAG);
    if (*FLAG == 2)
    printf("Input the file name in the form - drive:name.ext\n");
    printf("For example: A:OUTPUT.DTA\n");
    scanf("%s", NAME);
    *OUP = fopen(NAME, "w");
    else
    *OUP = stdout;
    printf("Select amount of output\n");
    printf("1. Answer only\n");
    printf("2. All intermeditate approximations\n");
    printf("Enter 1 or 2\n");
    scanf("%d", FLAG);
    fprintf(*OUP, "FIXED-POINT METHOD\n");
    if (*FLAG == 2)
    fprintf(*OUP, " I P\n");
    /* Absolute Value Function */
    double absval(double val)
    if (val >= 0)
    return val;
    else
    return -val;

  • Why is "x2^0" Displayed on Fixed point numbers in hex format

    I have a requirement to display a fixed point value (unsigned 20bit value) in hex format. At present when I set the numeric indicator to display this I get a "x2^0" string attached to the end.
    What is this and is there anyway of turning it off?
    I am trying to give a display that replicated some old style hex mechanical switches, by selecting a fixed size font and limiting the display to only be big enough to display the five hex digits (minimum field length 5 with pad with zeros) I get almost what I want (the "X2^0" is hidden of right hand side)
    However when I delete characters from the number (to say enter a new number) the "X2^0" part then shows. See attached jpg which shows the format string.
    This is by no means a show stopper but just annoying, is there some where to turn this formatting string off?
    Dave.
    Attachments:
    20 bit hex.JPG ‏52 KB

    It is showing how many of those bits are for the decimal places.  It is kind of important information.
    But since you are dealing with an Unsigned Integer (20,20 means there is no fractional part), why not just use a U32.  You can set the display of the indicator for that to be %05x to just display the lower 5 hex characters.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • 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

  • Fixed point division on FPGA doesn't show the fraction part

    Hi,
    I'm trying to normalize a fixed-point complex vector. My problem is in the part of fixed point division. Assuming I am dividing x by y (x/y), then I multiply first x by 2^26 and y by 2^9 then divide both of them using high throughput function then multiply the result by 2^-17 and here the problem appears. The result is zero, and the fraction part doesn't appear. My question is: does the "scale by power of 2" block discards the fraction part and only keeps the integer part, even if the input is a fixed point input with fraction part of 20 bits length? If so then how can I get the result of dividing a number by a bigger one? I mnean how can I display a result < 1? If not, then why isn't the fraction part displayed? The numbers I used as an example are: x=10, y=182.
    The indicator is adjusted to have 64 bit word length and 44 integer length. I also write this data into a memory element and then read it through a FIFO to transfer it to the RT vi. Both of the memory and the FIFO are configured with the same word and integer lengths above. I am using 7965R series FPGA.
    Thanks in advance.

    It's worth noting that I tried this same procedure on RT vi itself and the fraction part was displayed.

  • Need arithmetic operation result in Fixed point arithmetic disabled prg

    Hi,
    I am writing an enhancement which is in standard SAP program which is not enabled for 'Fixed arithmetic' calculations.
    I need to do some actual arithmetic operation involving packed numbers in my enhancement.
    Say 
    p1 = '2.00'
    p2 = '12.00'.
    result = p1 * p2.
    result coming is 2400.00. This is because Fixed point arithmetic is disabled in standard program.
    I need a result of 24.00 . Is there any solution to this apart from dividing it with 100?
    Regards,
    Dhana

    based on P1 and P2 values you need to divide the value with 100 or 1000 as per the number of decimals on P1 and P2

  • How can I display date+time and not the point number in excell?

    Hi everyone,
    Could anybody tell me how I can save date + time to a file, so that  I can display on a diagram(excel) : date+time in (ox) and data (oy)? :
    My program sets in (ox) the point number and not the date+time....( although  date and time are written correctly in the column...)
    Any help would be great,
    Thanks,
    regards,
    Marc

    hi there,
    excel uses 01.01.1900 00:00 as the time offset, LabVIEW uses 01.01.1904 02:00, so you can't display the correct datetime in excel when you write the time as a fractional number of seconds from LabVIEW. you must format the datetime in LabVIEW to a string and write that to the column. use the "Format Date/Time String" - function and for example "%d.%m.%Y %H:%M:%S%3u" as the format string (see the functions help for more examples). you also could format your data to a string using "Format Into String" - function and write the file as a 2D string array. the decimal point you have to use depends on your system and its settings, but you can specify the decimal point in the Format string like "%.;%f" (means fractional number with point as decimal point).
    best regards
    chris 
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"

  • 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

  • Usage of NOT having Fixed Point Arithmetic?

    Hello!
    SAP recommends to always do programs with Fixed Point Arithmetic attribute checked. Please don't explain here what is Fixed Point Arithmetic - I know this and it's is not my question.
    The question is: why do we have it at all? Why aren't all programs simply fixed-point-arithmetic without attribute to activate or deactivate this?
    I suppose that there are situations which require Fixed Point Arithmetic NOT being set, but I can't imagine any. Could anyone offer an explanation?
    Thanks in advance!
    Igor
    Edited by: Igor Barbaric on Mar 21, 2008 9:30 AM
    No replies - I'll try to bring the question to your attention once again:
    Please, does anybody know the purpose of NOT having Fixed Point Arithmetic?

    Please check if this helps u
    This attribute defines, whether for numerical data objects of data type p (packed numbers) is the decimal point is relevant in calculations or assignments or if it is omitted. Normally, this attribute is always switched on and you might ask, why it can be switched off at all. Well, in very ancient times packed numbers had no real decimal point. It was taken into account only for presentation purposes. In order to stay downward compatible, for the introduction of fixed point arithmetic this switch was needed. In fact there are still programs that switch fixed point arithmetic off ¨C for example financial programs that calculate on the basis of cents instead of dollars.
    Thanks Arjun

  • 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.

Maybe you are looking for