Suggestions on: Double to 2 Significant Digits

I read a post the other day about how someone trunkated a double value to 2 or 3 significant digits, now I can't find the post. Does anyone know good ways to calculate a double value and show it in JTable in 2 significant digits?

Is there a simple 2 or 3 lines of code I can append to this that will set the column to have a format of 2 decimal places?
TableColumn diaColumn = table.getColumnModel().getColumn(DIA);
diaColumn.setPreferredWidth(40);
//diaColumn.setFormat(2decimalplaces); something like this suedo code?

Similar Messages

  • Double parsing and significant digits

    Does anyone know why I am getting extra significant digits from the parse methods and how I get around this problem?
    Code:
    double value = Double.parseDouble("12398.7");
    System.out.println("double="+value);
    value = value/100.0;
    System.out.println("double/100.0="+value);
    double fvalue = Float.parseFloat("12398.7");
    System.out.println("float="+fvalue);
    fvalue = fvalue/100.0;
    System.out.println("float/100.0="+fvalue);
    Output:
    double=12398.7
    double/100.0=123.98700000000001
    float=12398.7001953125
    float/100.0=123.987001953125
    Here�s what I wanted:
    double=12398.7
    double/100.0=123.987
    float=12398.7
    float/100.0=123.987

    Does anyone know why I am getting extra significant
    digits from the parse methods and how I get around
    this problem?Yes, many people know why you are getting extra digits and how to get around this problem. See the thread titled "Why ?? 0.4 + 0.3 + 0.3 = 0.9999999999999999", or any of hundreds of other threads about binary math.

  • Significant digits not obeyed when value set through property nodes

    Hi, I have a front panel with a large number of indicators on it. As updating each one is a very straight forward task, I am using the This.Panel.Controls array to step through and update each indicator appropriatly. The problem is, that because I have so many indicators, and the actual numbers aren't that important (they are also being logged elsewhere) I only wish to have 4 significant digits displayed so that the value fits into the size of the indicator. I set each indicator to have a display format of %_4f, but when I run it this is not obeyed and 7+ digits are displayed. I'm guessing this has something to do with updating the controls via the property node, but I'm not sure why that should cause an issue. Any ideas?

    Nope, I double checked the format string. I do mean significant digits by the way. My imput values are expected to be in the range 0-100 but I've sized my indicators to fit only 4 digits, which will give me at worst a 0.1% error over the full range, which is good enough. Right now the channels from which I am grabbing data are all disconnected, so I am just getting noise. I've attached images of both the format string I'm using, the relavent part of my code where I update values, and an example of the output I get. Thanks,
    Jon
    Attachments:
    FormatString.PNG ‏32 KB
    ouput.PNG ‏2 KB
    ValueUpdating.PNG ‏25 KB

  • Java does not understand significant digits?

    Hi, everybody:
    Java states that if you multiply two float variables, you have to declare the product as a double, because if the two operands, for example, each have four decimals places, then the result may have eight decimal places.
    The mathematical concept of significant digits states this is untrue. If each operand is carried out to four decimal places, the product of the two can be no more accurate than four decimal places, which would require the product to be only a float, not a double. For instance, 2.123456789 x 2.1 = 4.5, not 4.4592592569. In this case 2.1 is only accurate to one decimal place, so the product can be no more accurate than one decimal place.
    When I try to declare the product variable as a float I get a compiler error stating a loss of precision, and I'm forced to use improper math and allocate more memory than necessary by declaring the product variable a double.
    Anybody have any insight into this?
    Thanks,
    Rob

    Java states that if you multiply two float variables,
    you have to declare the product as a double, because
    if the two operands, for example, each have four
    decimals places, then the result may have eight
    decimal places.
    Which is quite correct.
    The mathematical concept of significant digits states
    this is untrue. If each operand is carried out to
    four decimal places, the product of the two can be no
    more accurate than four decimal places, which would
    require the product to be only a float, not a double.Which is a very weird concept you're using.
    0.5 * 0.5 is exactly 0.25, yet under your logic it would never be significant to more than one decimal place, so either 0.2 or 0.3.
    >
    Anybody have any insight into this?
    Take some math classes.
    Your core understanding is fundamentally flawed.

  • Significant digits from Property Loader

    Hello guys,
    I'd like to know if anyone already faced that issue, if I load a certain limit from property loader, for example Minimum "10.0", and the VI returns a measure of 9,999472894, the test should pass.
    Is there some easy way to detect the significant digits from the property loader, and automatically apply that rounding to the measured values? Actually it would become heavy to program it test by test.
    Perhaps in my .xls property fils I could put an integer for each limit that represents the number of significant digits...
    Any better idea?

    Correct, TestStand does not base the signficant digits of the comparison off of the significant digits of the given limits, instead it assumes you want a comparison done within the full precision of a double-precision floating point number.
    To fix existing limits, you could write a converter that converts limits like 10.0 to 9.999 since it is a mechanical process that could be done programmatically. Not sure why you would have to hard code limits to fix this problem. Is it not possible to change the limits in the property loader source to 9.999 or that is not an option? If that's not an option, another idea is that we ship the source code to the property loader, you could modify it to convert limits to their precision range values, for example, if a limit of 10.0 is loaded as a lower limit, it could automatically convert it to 9.999 before setting the limit value in the teststand step. That way you wouldn't have to change any sequence files, just the property loader itself.
    Not to say it wouldn't be useful to add a new feature to TestStand to match the precison of the comparison to the precision specified by the limit (or perhaps in a separate setting on the step), but that is not a common request. You could post such an idea to the idea exchange though and see what people think.
    -Doug

  • Significant Digits to Digits of Precision by default?

    Howdy,
    Is it possible to set the default precision for front panel numerics to, say 4 Digits of precision, instead of 6 Significant digits? I prefer digits of precision, and I always have to change each and every control and indicator. Is this selectable somewhere?
    Thanks!
    B-)

    I agree it would be useful to set global defaults for formats and other cosmetic properties.
    I typically want a fixed decimal resolution and the numbers right-aligned. I will never understand why all numerics are left-aligned.
    If I change an integer to hexadecimal or binary format, I want it padded with zeroes on the left and the default number of digits corresponding to the data type (e.g. U8: 8 digits for binary and 2 digits for hex).
    There is always the product suggestion center.
    LabVIEW Champion . Do more with less code and in less time .

  • How do I change the number of significant digits in a slide's digital display?

    I suspect I'm missing something really obvious. I want the slide's digital display to show 1.23 instead of 1.23456. Here's what I tried:
    1. Drop a Horizontal Pointer Slide
    2. Make its Digital Display visible
    3. Type 1.23456 into that display
    4. Pop up on the Digital Display and select "Display Format..."
    5. Change the number of significant digits to 3 and hit "OK"
    The digital display still shows 1.23456. What am I missing?
    Solved!
    Go to Solution.

    LOL - I had the same problem.  Hidden in plain sight!  All I saw was Numeric, and thought "Duh! Of course it's numeric - it's a slider!"
    I do think NI could do a much better job on this, perhaps with more informative labelling.  Slider Scaling or Scale Format might be better.  Also, since one can select the Digital Display by itself on the front panel, one should be taken directly to the digital display formatting when Properties is selected, instead of still having to change the dropdown. By selecting the digital display instaead of the slider, you're implying that you want to change its format only.

  • Flatten to string with significant digits

    I was using NumberToFractionalString to convert a double to a string, but I was specifying a width of 5 and precision of 2.  Now, however, I want to FlattenToString the double.  I'm not sure if I need tp specify any precision for my application, but if I wanted to maintain the 5::2 using the FlattenToString, is there a way to specify that?

    Flattening to a string is not a formatting operation, but something that retains all original bits in the DBL. It has no concept of cosmetic formatting terms.
    Do you simply want to round your values to two decimal digits? Be aware that this is not possible when retaining binary representation.
    LabVIEW Champion . Do more with less code and in less time .

  • Digits of precision limit to 3 significant digits

    Hello!
    I need 3 signifcant digits. If I choose 13 digits, it gives me 2 places. If I choose 14, it gives me all places. Can you please see the attached VI and help me? I need 3 decimal places. Is this possible?
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    digits.vi ‏6 KB

    HI Susanne,
    you need to choose a display format of "%.3f". Change the properties of the numeric control accordingly!
    If you really insist on "3 significant numbers" you need to choose "%_3f", but all this is available in the control's properties dialog!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Suggestions for backing up captured video digitally

    Hi all,
    My church is using an Imac (2.4ghz/1gb ram) to capture video of our church sermons. We use a Panasonic GS-320 which runs through a WD MyBook 500 gb external HD then into the Imac. We capture in Imovie directly then let the video file sit. Our intent is to upload these videos to the net for later streaming and such. Our problem is that we have 13-15gb videos that just sit, and now both hardrives are full. We would like to render these huge files to something smaller for the purpose of archiving but have them at a resolution that is still editable and to also add in simple titles and such later on. Right now I'm rendering to .mov (mpeg 4) @ 720x480. Any suggestions?

    Archiving a smaller file at full-resolution is a bit of a contradiction! Especially when you add that you may want to edit that file later. DV material is 13GB/hour is arguably already the lowest file size you want for archiving/editing later. Smaller files via different forms of compression are meant for delivery, not archiving and/or editing. With a mini-DV camera you have the best archiving option of all formats: the tape itself. You could even send an edited sequence back to tape. To date, tape has been the most robust and reliable solution for any type of archiving. Data tape back up systems are fairly expensive. After DV tape comes hard drive storage. I strongly recommend investigating a hard drive tower. I personally use a MacGurus (http://www.macgurus.com/productpages/firewire/burlyfwenclosure.php) but there are several manufacturers. The advantage to such a system is that as hard drives fill up, you just pop a new one in and store the "old" one. And buying bare bones drive will save money in the long run over always buying a new external drive. And hard drives are cheap/GB. Cheaper than other storage methods. And faster. And besides tape, the most reliable. From there is is a simple matter of cost analysis: if a sermon is one-hour then you could fit let's say 30 sermons on one 500GB drive. A 500GB is roughly $100. That is $3 and change/sermon.
    Mike

  • How do I read a spreadsheet float with 15 significant digits?

    I am reading data in from a spreadsheet and some of the data has the following floating point values:
    xxxxxxxxx.yyyyyy
    As in 208394912.392452
    It seems no matter how I set the import syntax (ie - %9.6f, %_15f, etc.) it always gets truncated and shoved into SI format as such:
    208394912.392452 -> 2.083949E+8
    I have to retain every single value from the read, do you happen to know what syntax I would use to do such?
    Thanks!

    LabviewRules wrote:
    Hi Bilko,
    To be honest it is actually clean already and written with proper programming practices. It is just not in anyone's best interest for me to give a full and descriptive detail of my current application so I need to refactor and encapsulate to create a simple loading example data file and vi.
    I've been using lv for over 15 years and do try to keep my code up to shape at all times.
    Usually when someone says they want to clean up the code it's because of spaghetti mess.  Thankfully, you meant that you wanted to pare it down to make it more digestible for us. 

  • 64 bit: inconsistent plot commands

    A question, may be a comment:
    While PlotXY accepts various data formats, double, int, and ssize_t integers, the plotline command is limited to double. Hence, I can not use the same data set to plot a line if the data are ssize_t integers without getting compiler warnings 'Conversion from 'ssize_t' to 'double' might lose data'. Of course, the warning is correct, but why not permit plotting integers?
    (Background: sometimes events are counted and evaluated (normalized, offset corrected...) Using integers preserves precision, while at large numbers double values loose significant digits. Now, plotting a line from a large data set may be useful to connect two points from the data set, indicating a baseline ...) 
    Any recommendations? If not, may I suggest to update the PlotLine... commands to accept 64 bit integers, too?

    The plotting functions that accept arrays (PlotX, PlotY, PlotWaveform, etc...) can accept variable data parameters because they can simply declare those arrays as void *. But functions that take scalars (PlotPoint, PlotLine, etc...) cannot accept values of variable types in a single function. They could do it by forcing you to pass a pointer to the value, instead of the value, but that would also be more cumbersome since it would require you to always use a variable. You wouldn't be able to pass a constant instead.
    The warning from ssize_t to double makes sense (in 64-bit), but you can easily suppress it by casting it to a double when you pass it to PlotLine.
    Luis

  • Need a Suggestion For implementing the Digital Signature For the Documents

    Hi,
    Currently I am working in a Document Management System. I need a Good Suggestion for how to implement a Digital Signature For the Documents.
    Thanks in Advance
    Sabarish V

    Hmm, if you are not using Oracle Payroll, what are you using for payroll? I am wondering why you could not use your payroll system, whatever it is, to handle this reimbursement program.
    Well, you may want to talk to Oracle support about how to handle this in Oracle iExpense. You can certainly handle advances for Expense Reports. You would then apply the advance to the expense report items. The catch is I don't think you can stop expense item entry after the adavance is satisfied. You would have to set up a work flow process of some kind to have the expense reports reviewed and only approve expenses that are applied to the advance, is what I am thinking. Not your ideal solution, but something to think about. It could be the Oracle folks might know of a sneaky way to handle this. What you are trying to do is unusual. Employee advances are common, but the idea of not being able to exceed the advance amount is what unusual about this. Normally you will accept any expenses over the advance amount and reimburse the employee for those extra amounts not advanced.
    Good luck.
    John Dickey

  • Java Double summation is not working properly

    public class Test {
         public static void main(String[] args) {
              double d = 0.6+4.6;
              System.out.println(d);
              /*float d2 = (float)(0.6d+4.6f);
              System.out.println(d2*1.0f);*/
    This is printing 5.199999999999999.
    I am using Java 1.6. Please suggest me how to do these type of double operations.

    >
    If d was as defined in the original post you don't get the expected result
    >
    That statement is not quite correct. Of course you get the expected result.
    Perhaps you meant to say 'you don't get the OP's expected result'?
    And I did read it all before I answered but it seems you misread Kayaman's response.
    Kayaman said
    >
    . . .you can't just do
    if(d == 5.2)
    with floating point numbers.
    >
    and, as I showed, that is clearly incorrect. You not only can do that but that is how you would check for equality with a particular value.
    The OP concluded
    >
    if the program is like this, false is printing. But the answer should be true.
    >
    I think we all agree that the OP is wrong that the answer should be true.
    But he is not wrong because you can't do 'd == 5.2' with floating point numbers.
    OP is wrong because comparing two numbers like 'd' and '5.2' that have any significant digits that differ will not result in equality.
    And neither Kayman nor you gave the OP that real reason why the code took a different branch than what the OP expected.
    My statement
    >
    The OP used 5.199999999999999 and that isn't equal to 5.2 so you take the FALSE branch.
    >
    is EXACTLY the explanation for why the OP's assumtion is wrong.
    The reason has nothing to do with the Java syntax.

  • Subtracting very small double value

    i'm having trouble figuring this out..i'm sure it's a simple solution..anyhoo..i'm trying to run the following line of code
    value=1-((1-b1[8+(i%classes)])*(1-b2[4+(i%classes)]));
    let me point out that value is a double value, and b1 and b2 are double arrays...
    the values of b1 and b2 are very small(around E-60)
    the PROBLEM is that value returns 0.0 when i run my code instead of the small value. I'm sure it's something I'm doing/not doing, but I'd appreciate some help on what is going on. Also as a note, I'm running J2SE 1.3.1. I saw on the API that the min double value is supposed to be around E-324 but any suggestions people? Thanks!!

    1-b1[8+(i%classes)]This is 1 - (10^-60), right? A double value only has about 16 significant digits, not 60, so the nearest possible double number to that is 1. Hence you get 1 - 1*1. There's a whole school of mathematics called "numerical analysis" that deals with questions like this. In this particular case, if b1[x] and b2[x] are always extremely small, you should evaluate the expression in advance so that it looks like b1 + b2 - b1*b2, which in turn will round to b1 + b2.
    PC²

Maybe you are looking for

  • Problem with RMI in ADB T75 receiver

    Hi: I have a problem with an xlet that uses the RMI (IXC) API in the ADB T75 development settop box. I export an object (of type MyObject) implementing the Remote interface, and, later, I import it with no problem. The problem appears after importing

  • Substitution for FI document

    Hi All, Our requirement is to replace XREF3 field in BSEG with Vendor name. So we are trying to implement substitution in OBBH transaction using exit for BSEG-XREF3. We had copied RGGBS000 into zRGGBS000. In GET_EXIT_TITLES cretaed one record for EXI

  • HR ALE : Error in Idoc Status table

    Hi, We are transporting HR Master data from one client to another (message type HRMD_A) and extension ZRMD_A06. For this purpose we are using the PFAL transaction. So far, we are able to send employee data to the receiving client, all Pnnnn tables al

  • Free Version CONVERT PDF to Word doc

    Is there a FREE VERSION of Convert PDF to Word doc.

  • How to create ISO for Different Discrete org

    Hi, We need to raise the Internal requsition within Discrete org codes, but system not permit to make the IR, In source side displays as "Supplier" instead of "Inventroy", Pls helps us to solve this issue Thnx, Udhayan N