RE: Floating point exception in TGraph::PaintPolyLineHatches

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Thu, 20 Mar 2008 18:20:36 +0100


Hi,

I see your point and I totally agree with you. I tried to change all the ATan by ATan2 in that code. But, unfortunately, some examples I have to test this code are failling. So a simple one to one change is not the solution. It requires a close look and careful testing. Thanks to have reported this bug I will fix it as quickly as possible.

Cheers, Olivier Couet

-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of Nick West
Sent: Thursday, March 20, 2008 5:41 PM
To: roottalk_at_root.cern.ch
Subject: [ROOT] Floating point exception in TGraph::PaintPolyLineHatches

Dear Roottalk,

We (MINOS) have noticed that the following macro:-

  {

     (new TH2D("axes", "axes", 100, -5, 5, 100, -5, 5))->Draw();
     TGraph* g = new TGraph(2);
     g->SetPoint(0, -1, -5);
     g->SetPoint(1, -1, +5);
     g->SetLineWidth(1001);
     g->SetFillStyle(3004);
     g->Draw("l same");

  }

works fine if run in ROOT but fails:-

  Floating exception

if we run it in our off-line framework which is based on ROOT. Going in with the debugger reveals the source of the exception:-

  0x013aeade in TGraph::PaintPolyLineHatches (this=0xa67ecb0, n=2,x=0xa5a4b28, y=0xa5a4ba0) at graf/src/TGraph.cxx:3578   3578 a = TMath::ATan((yf[1]-yf[0])/(xf[1]-xf[0]));   Current language: auto; currently c++
(gdb) print xf[1]

  $1 = 0.42000000074505811
(gdb) print xf[0]

  $2 = 0.42000000074505811
(gdb) print yf[1]

  $3 = 0.61286863017098181
(gdb) print yf[0]

  $4 = 0.068096517282101213

so (xf[1]-xf[0]) is zero and (yf[1]-yf[0]) is not.

In our framework floating point exception is not disabled. Now we can quite understand why, for interactive work, floating exception suppression makes sense but would it be possible to catch cases like this as and when they get reported? In this case simply changing to ATan2 would suffice.

Thanks,

Nick West. Received on Thu Mar 20 2008 - 18:20:43 CET

This archive was generated by hypermail 2.2.0 : Fri Mar 21 2008 - 05:50:03 CET