Test a double for NaN, Infinity or -Infinity

Hello,
My program uses JFreeChart library to plot a series of XY data plots.
I Have some data that is loaded into an array from a tab delimited ASCII file supplyed by an ADC.
Thats all good.
I then take my data and calculate its gradient rather simply using dy/dx .... subseqent values of y divided by subsequent values of x
This results in some gradients but also some NaNs and Infinities.
I guess these come from where my data is doing : 0/n, or n/0
When I try to plot the NaNs and Infinities my JFreeChart doesn't like it.
How do I test for infinities or NaNs in my Array and deal with them?
Here is some code that works but yields NaN and infinity values for some of the data:
        for(int i=0; i<StandardDevOfData.length ;i++)
                double diffiny = (myData.get(i+length).getCurrent() - myData.get(i).getCurrent());
                double diffinx = (myData.get(i+length).getPotential() - myData.get(i).getPotential());
                double Gradient = (diffiny/diffinx);
                StandardDevOfData[1]= Gradient;

eenzc wrote:
How do I test for infinities or NaNs in my Array[Double.isInfinite(double)|http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html#isInfinite(double)]
and
[Double.isNaN(double)|http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html#isNaN(double)]
and deal with them?Depends. :)

Similar Messages

  • How to catch NaN, infinity errors?

    Example lets say i want to detect a NaN error
    when detected a error dialog appears
    taking this as an example
    String s;
            float Number;
            double Ans;
            s=txtNumber.getText();
            Number=Integer.parseInt(s);
            Ans= Number*2;
           s=String.valueOf(Math.toRadians(Ans));
          txtProduct.setText(s);
         } if ((Ans).equals("NaN"))
          if(true){
          JOptionPane.showMessageDialog(null,"Try Again.","Inane warning",JOptionPane.ERROR_MESSAGE);Can some1 tell me where i am wrong this works but for everything
    including Nan and Infinity i only want to detect NaN or Infinity
    now ive tried the second method isNaN and isInfinite
    if((double).IsNaN(Ans)); II .IsInfinite(Ans)
    if(true);  same as above public boolean failed to detect NaN or Infinity either returns true when its not false when its not
    with the dialog message keeps poping up
    and
    even with catch
    try{
    Ans=Number*2
    }catch (ArtithmeticException e) method the second and third dont give errors and they dont even detect NaN nor Infinite when the dialog is to show it doesn't
    ive tried this aswell
    if (txtProduct.setText(s).isNaN(Ans)){
    if(true){
    dialog should appear
    i get an error saing double or float or void cannot be differenced
    im posting this here for the experts who can figure this out
    try test the simple code before i could work and implement a more complex one later
    your help on this one
    thanks
    Edited by: AK-Emm on Sep 5, 2008 7:29 PM

    AK-Emm wrote:
    float Number;
    double Ans;
    Number=Integer.parseInt(s);
    Ans= Number*2;
    if ((Ans).equals("NaN"))
    You have an integer, which you convert to a float and then a double. You then check if it is NaN. There are no integer values for which this sequence of operations will produce a NaN.
    Are you coming from working in a language where 'NaN' is used to signify that parsing the string failed? In Java, the method throws NumberFormatException rather than returning NaN. This is done so that client code is simplified as the error handling is separate from the main flow, because NaN is a double not an int and Java is mostly strongly typed, and because Double.parseDouble("NaN") should return NaN without it being an error.

  • 18 Month Contract For BT Infinity

    I got a phonecall the other day from someone from BT trying to sell me BT Infinity, I've been thinking about moving to them for a while now but I'm not a fan of this 18 month contract, I'd much rather a 12 month contract.
    Can this be negotiated?
    Also if I do decide to signup for BT Infinity do I have any rights if I'm not happy with the speed, i.e. can I opt out of the contract if I'm not happy? Basically I only want BT Infinity if I can get 40mb Down, 10mb Up speeds, I've tried the checker and it states I can get these speeds (I live around the corner from the exchange)

    PaulNI wrote:
    I got a phonecall the other day from someone from BT trying to sell me BT Infinity, I've been thinking about moving to them for a while now but I'm not a fan of this 18 month contract, I'd much rather a 12 month contract.
    Can this be negotiated?
    Also if I do decide to signup for BT Infinity do I have any rights if I'm not happy with the speed, i.e. can I opt out of the contract if I'm not happy? Basically I only want BT Infinity if I can get 40mb Down, 10mb Up speeds, I've tried the checker and it states I can get these speeds (I live around the corner from the exchange)
    Hi Paul, I would imagine they would insist on the 18 month contract for the price they are quoting.
    You have seen the post about the minimum, but you say:
    "Basically I only want BT Infinity if I can get 40mb Down, 10mb Up speeds, I've tried the checker and it states I can get these speeds"
    I would be very surprised if it stated that you would get, it most likely says:
    "Our test also Indicates that your line currently supports a fibre technology where consumers have received a downstream  line speed of xx Mbps and upstream line spead of xx Mbps.
    The actual stable line speed supportable will be determined during the first 10 days of use."
    The wholesale checker is normally conservative so you should get the speeds quoted or more, but that is not guaranteed.
    Once the service has started, so does your contract.
    toekneem
    http://www.no2nuisancecalls.net
    (EASBF)

  • Yosemite and popup ad for Comcast Infinity wifi.

    Just downloaded Yosemite.  Now every time Safari is opened I get a popup ad for Comcast Infinity wifi.  How do I stop this??  It's really annoying.

    1. If adware is installed without your knowledge,
        use  free  AdwareMedic by clicking “Download ” from here
         http://www.adwaremedic.com/index.php
       Install , open,  and run it by clicking “Scan for Adware” button   to remove adware.
       Once adware is removed, quit the app by clicking AdwareMedic in the menubar
        and selecting “Quit AdwareMedic”.
    Safari
    2. Safari > Preferences > Extensions
        Turn those off one by one and relaunch Safari again to test.

  • Accurate Exchange Upgrade Dates for BT Infinity?

    Is there anywhere online that details the exact or most accurate information on when your local exchange will be upgraded for BT Infinity?
    I've been patiently waiting for my exchange to be upgraded (STBSETT, Bassett, Hampshire) and was pleased to hear a rumour that it was happening for Southampton Sept 2011 which I'm assuming my exchange comes under. However when I check online at sites like Samknows it doesn't state anything. I'd like some accurate information please.

    Hi All infinity install dates are estimates this link should help http://www.openreach-communications.co.uk/superfast/where-and-when/default.htm
    If you want to say thanks for a helpful answer,please click on the Ratings star on the left-hand side If the reply answers your question then please mark as ’Mark as Accepted Solution’

  • Want to register for BT Infinity

    You go through the website, all the links point to BT.com/infinity but when on the page, there is no form or place to sign for interest.
    The Exchange in Barnet is upgraded for BT infinity, some of the cabinets are done but talking to sales and re visiting the website, still no joy on when the roll out for the fiber optic circuit will be for EN4 8BG. Frustrating!!!!!
    Surely BT can make it simpler to register for interest in BT Infinity.
    Solved!
    Go to Solution.

    BT is making so difficult for to place order for BT Infinity. They spend enough time on tele sales but when i call them to place an order. It is remindimg me off the old days of BT or should I say Post Office when one waited for telephone line for months.
    I have checked with BT infinity website for eligibilty and my address can have new Bt Infinity.
    Please someone at BT Infinity sales review your procedures and make it easier for a direct customer to place an order.
    Your are pushing me towards going with different vendors,,,,,,,
    Wake up!!!!

  • Paying for BT Infinity but still getting ADSL conn...

    Since I've upgraded to BT Infinity from Total  Broadband, there has been no change in connection or download speeds (even when ethernet cable is plugged in) - now I know why. I am clearly not connected to BT Infinity. I'll tell you how I know. Today my internet went down. I clicked on BT Desktop Help who said I wasn't connected and sent me to the BT Home Hub Manager page:
    http://bthomehub.home/index.cgi?active_page=9142&a​ctive_page_str=page_interception&req_mode=0&mimic_​...
    Just in case link doesn't work, the basic 'wordage' is below:
    Can’t connect to Broadband
    ADSL or Ethernet
    To help us diagnose the problem please select the
    type of Broadband connection you have.
                  -----  ADSL connection
                        "ADSL Connection"
                  -----  BT Infinity Connection     
                        "I connect to Openreach
                        equipment and it plugs
                        into the BT Infinity port
                        on my BT Home Hub."
    Naturally, I clicked on 'BT Infinity Connection'. I tried several times as it was 'trying to connect'. I waited up to half an hour each time to no avail. NB - I was told 'this will take a few minutes' each time.
    Just out of curiousity, I clicked on 'ADSL connection' --- it connected to the internet straight away!
    I conclude that I am NOT connected to "Openreach equipment that plugs into the BT Infinity port on my BT Home Hub". (BT Home Hub 3 that is!).
    It looks like I haven't been upgraded at all.
    I'm paying for BT Infinity, so why am I not getting it??   

    Sorry, just to clarify you have the white modem from Dave's picture?
    But the Red cable is going to the ADSL port on the HomeHub 3 and not the Infinity port? If so try putting it into the Infinity port and see if you can connect (I'm guessing it will be no). If that doesn't work just switch it back then contact the moderators.
    You can contact the moderators here, they will take personal ownership over your case until resolved.
    They normally respond within 3 working days.
    If this helped you please click the Star beside my name.
    If this answered your question please click "Mark as Accepted Solution" below.

  • LSO - Test Time doubles in the Learning Net

    Hi Experts,
    I have created a Final Test using author tool. The attribute for the Test "Maximum test time (minutes)" which is set , works fine when i run Test Preview through the Author Tool.
    But when i play the complete course, i.e. the Learning Net, through Content Player, the test shows Double the time mentioned in the Author Tool.
    I hope someone can help me with the solution
    Regards,
    Shweta Thakkar
    Edited by: Shweta Thakkar on Dec 19, 2008 6:45 AM
    Edited by: Shweta Thakkar on Dec 19, 2008 6:46 AM

    Hi Tania,
    Setting the switch to 1 did not help me.. it was already one... tried changing values.
    The problem was i guess with the AE maybe or with the Windows VIsta on my system.
    There was no issue when i tried running the same on other system where there was no vista. Windows Vista needs a separate version of AE. So i really do not know wehre the issue was...
    Good luck!!
    Shweta

  • I can't get FaceTime or iMessage to connect, I enter valid password (tested and works for Apple account) and it won't connect. I have checked all settings, upgrades iOS to 8.3 rebooted, changed Apple acount PW still wont connect. My internet connecti

    I can't get FaceTime or iMessage to connect, I enter valid password (tested and works for Apple account) and it won't connect. I have checked all settings, upgrades iOS to 8.3 rebooted, changed Apple acount PW still wont connect. My internet connection is fine Safari works and I can access all sites. I have an iPad 2. Any help on this will be greatly appreciate.  iPad 2, iOS 8.3

    This is an ongoing problem as you will see by searching the forum. 
    Out of curiosity, do you have 2 step verification enabled?  It was recently extended to include iMessage & FaceTime & I'm wondering if it might be causing some of the issues that some users are experiencing.

  • Are we Beta testing the N97 for Nokia?

    Because if i was given this as a beta release i would have told them what i thought, the current launch version on the N97 with V10 firmware is barely an Alpha release, this phone was a rush job thrown out on the market to coincide with the launch of the iphone 3Gs.
    This is my fourth N series, N80, N95, N95 8gb (the best N series yet), and now this N97 what should be Nokia's flagship, but being stripped of apps and filled with Trial versions to please the accountants at Nokia.
    Day one and it locked up twice, corrupted my contacts when synced with OVI, and ran down to less than 4mb on the C drive, day 2 i found the GPS was not working, it was a joke, walking down the road under a clear sky and it could not hold a signal lock, driving was worse barely holding a signal for a few seconds and as for sitting spinning it round for an age to get the compass to work........forget it id rather be lost than look like a **bleep**.
    Deleting apps and reinstalling them on the mass memory frees up some space, but why should we have to do this, the whole phone is badly thought out and configured.
    Soon after the stylus supplied with the phone and attached to the phones only tie point scratched my screen, what was wrong with a rear cover with a bump and a thin PDA style stylus, no not good enough for Nokia, a fat thing on a string will do for them. 
    New Firmware release 4 days after UK launch and still not available to most users as it has not been network approved yet, 3 network say its Nokia's job and they are delaying things, Nokia say its the networks delay. Come on if it was needed that quickly why leave most of your customers waiting, or just get to work on a layered OS with a standardised core with a network layer, so everyone can have the updated without waiting.   
    4 weeks in on this phone, i too have the scratched camera lens, still No working GPS, and having some good negotiations with Three to try to reverse the contact upgrade, as i don't think another N97 will last any longer than this one.
    I see Nokia spending Millions on punting the N97, TV, Billboards, Net adds, why push so hard on what is a sub standard product, could you imagine Joe public trying to free off some memory by moving apps, tell the care centres to brace themselves the N97 flood will be coming their way.
    What next, well if 3 don't cancel the upgrade, then Nokia will have to fix my phone again and again and again untill it works as advertised, in the mean time i am off to get in touch with watchdog so they can let Joe Public know what to expect from an N97.
    Rob 
    Solved!
    Go to Solution.

    I don't believe we're beta testing the N97 for Nokia. Beta testing suggests it is in a state prior to production. Nokia's track record (at least to me) seems that leading edge phones never reach a stable plateau.
    What I believe happens is the phone is released and remains unstable until they sort of perfect the platform, then a new handset is released bringing a whole new world of bugs and problems and so the cycle continues.
    By the time the phone is suitable for every day use it is, by today's technological stance, ancient and the damage has already been done to the reputation.
    S40 phones seem to fare much better, mainly because it is much more widely used within Nokia. S60 is up against some fine competition from vendors who will rush fixes out.. Nokia only ever seems to rush phones out. It isn't the same and it shows (see their forcast for the next 6 months)
    I honestly would not be surprised if this flagship phone limps on in a partially functional state until it is superceeded by a budget blackberry clone.
    Sad? Very! Am I being cynical, or telling it like it is.
    I'd be real interested to know if any exec at Nokia used the N97 in the weeks before it was released.. Not that I'm a fan, but we all know Stevie J used an iphone long before it was released.. I kind of get the impression they must all use very basic "corporate" s40 handsets and assume their flagship product must be of the same calibre.
    Next release, why not give 100 people N97 for testing, real testing.  It seems Nokias quality assurance team is out of touch with what a $700 handset demands.. ooooh, I gasp in awe at your 30 MB of free capactity when you remove ALL the applications you can. (It's like having a 2TB hard drive in a computer and continuing to boot from a floppy)
    I appreciate there are product time lines to meet, but if Nokia were aiming to compete with the likes of the pre, iphone and the various android handsets (not even mentioning windows mobile) rushing out a phone like this was very wide of the mark. Concept wise, the N97 is a great design.. the implementation of both the hardware and software just isn't going to cut it in todays market.. 
    (but this is what they want? you'll get bored with the handset and buy a replacement! yeay!)

  • I'm doing a scan around a line by sampling data 360 degrees for every value of z(z is the position on the line). So, that mean I have a double for-loop where I collect the data. The problem comes when I try to plot the data. How should I do?

    I'm doing a scan around a line by sampling data 360 degrees for every value of z(z is the position on the line). So, that mean I have a double for-loop where I collect the data. The problem comes when I try to plot the data. How should I do?

    Jonas,
    I think what you want is a 3D plot of a cylinder. I have attached an example using a parametric 3D plot.
    You will probably want to duplicate the points for the first theta value to close the cylinder. I'm not sure what properties of the graph can be manipulated to make it easier to see.
    Bruce
    Bruce Ammons
    Ammons Engineering
    Attachments:
    Cylinder_Plot_3D.vi ‏76 KB

  • Install a Test/Dev instance for SAP MII.

    Hi,
    I want to install a test/development instance for SAP MII on my laptop [2 GB RAM].
    Per my understanding, for this i would need set up SAP NetWeaver CE instance and deploy SAP MII 12.1 component.
    I also want do some custom development & integration with SAP through MII to SAP ME.
    As per Master Guide SAP MII 12.1.pdf, we need to Install SAP NetWeaver CE 7.1 EHP1 SP03.
    Since its a test/development instance can i install [SAP NetWeaver Composition Environment 7.2 Developer Edition|http://www.sdn.sap.com/irj/scn/downloads?rid=/library/uuid/a0a6bd7b-3dfc-2c10-eb95-aae0f777d4ab] and deploy MII.?
    Or do i need to have some specific version of Netweaver CE.
    Please let me know what are steps to install a Test/Dev environment for SAP ME/MII integration..
    Please advice.
    Thanks un advance.

    MII 12.1 has not been validated on NWCE 7.2.  And MII 12.2 is validated on NW 7.3, skipping NWCE 7.2.  It may install fine, but you will most likely run into problems executing some of the functions and features of MII.
    Regards,
    Mike

  • Double for loop

    Hi,
    I am trying to modify the content of a 2D for loop using a double for loop. But the result I am getting is always 0 in the loop i am getting... I am not really too sure of the problem. Can anyone help?
    Thanks
    Attachments:
    example2.vi ‏32 KB

    The results are not 0. the VI has replaced all of the elements in the intial array with random numbers. You've got an initial array with 3 rows and 3 columns but your inner for loop iterates 10 times. You cannot do a replace array element on an array element that is empty. You simply have to set the iteration count of the inner most for loop to be the same as the number of columns. You did that with the outermost for loop. Why did you use a constant of 10 for the inner loop?

  • Is there a way to test airport extreme for optimal function

    Is there a way to test airport extreme for optimal function?

    In your Mavericks OS X.
    Go to the WiFi icon on the top right.
    Hold the option key and click.
    At the bottom of the list you will see "Open Wireless Diagnostics"
    Open this and you can diagnose your wireless network.
    While it'sopen hit the Command + 2 and it will open the Utilities window.
    This will give you and overview of interference and what channel is best.
    You can alos run a speedtes over WiFi then run a speedtest directly connected with ethernet.

  • Assignment test in SAP for Logistic Invoice varification

    Hello Experts,
    We want to carry out Assignment Test in SAP for Logistic Invoice varification asp er the scenario:
    "The assignment text is a process step preceeding the invoice verification in background processing. The software checks cyclically whether an open goods receipt exists for the invoices entered in background processing. The software begins the invoice verification only when open goods receipts exist for an invoice. Effects on system administration are characterized as follows: the assignment test should be called in background processing before the report for the invoice verification, because the assignment test helps create the worklist for background processing. An assignment test is faster than a complete invoice verification in background processing, inasmuch as the software does not have to process as much data from the database and does not have to execute as many checks and reports. In addition, the software does not execute full assignment of the open goods receipts as in background processing; it executes only basic assignment"
    Please tell me if anybody has executed this and the required settings.
    Thanks,
    Radhakanta

    Hi
    The assignment filed material will be populated only for the documents after the Chnage in the G/L account.
    This change will not effect the Previous documents
    Mass change may not be posssible as accounting documents may not contain the same material.
    Thanks & Regards
    Kishore

Maybe you are looking for

  • Extractor file name

    Hi Guru: We are extracting data from SAP via flat file approach. Is there a way to get a dynamic file name? Like we have Dev/QA/PROD systems, how to makesure after transport, we do not need to change the file location/name? Thanks a lot. Best regards

  • Autodiscover insecure redirection error

    Hi Please excuse me here, I am very basic with Exchange 2013 or any Exchange for that matter. We have a SharePoint Server, which has Exchange Integration, and are experiencing some error when trying to sync calendar bits to Outlook. The error is as f

  • I don't have the option on Photoshop CC of using Photo Frames from the Fill Menu.

    Is this a bug? I have an Nvidia GTX 670 which is enabled in preferences. I have noticed some reference to items like Photo Frame being greyed out - it just does not appear on my PC.

  • Totally confused by network/VPN symptoms

    OK, I have an small business network 10.13.145.X. I have set up VPN to allow access to this from outside. When I use my VZW MiFi or COMCAST WiFi Hotspot. I can VPN in to the network and access resources. If I am at home on my home WiFi, I can NOT VPN

  • Long variable can not hold 20030414153045

    I have the following code long trackNo = 20030414153045 but the compiler keeps giving me error message: integer number too large: 20030414156060 but the maximum value for long should be greater than this, I am really confused, help please.