• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unexpected Signal : EXCEPTION_FLT_DIVIDE_BY_ZERO

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was doing some java programming on my windows xp platform when i encountered this error:
Unexpected Signal : EXCEPTION_FLT_DIVIDE_BY_ZERO occurred at PC=0xB7BD38
Function=[Unknown.]
Library=(N/A)
NOTE: We are unable to locate the function name symbol for the error just occurred. Please refer to release documentation for possible reason and solutions.
I fiddled around with my code but to no avail, and I am really stumped here. If anyone could help me out or give me pointers it'd be greatly appreciated. This is a bit lengthy (well, not that long) but I include my code below:
## I compile the files below with this line:
javac CatMouseChase.java Position.java Cat.java Mouse.java
*** CatMouseChase.java---------------------
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class CatMouseChase extends Applet implements ActionListener {
public void init() {
super.init();
nextStep= new Button("Move once");
add(nextStep);
nextStep.addActionListener(this);

ourWindowWidth = getIntegerParam("width");
ourWindowHeight = getIntegerParam("height");
myXCenter = ourWindowWidth/2;
myYCenter = ourWindowHeight/2;
int smallestDimension = ourWindowWidth < ourWindowHeight ? ourWindowWidth : ourWindowHeight;

double mouseAngle = getDoubleParam("mouseangle");
double catRadius = getDoubleParam("catradius");
double catAngle = getDoubleParam("catangle");
myUnit = (smallestDimension/2 - BORDER)/((int) (catRadius+1.0));

myCat = new Cat (new Position (catRadius, catAngle));
myMouse = new Mouse(new Position(1.0, mouseAngle));
statusString = "Chase is in progress.";
}

private int getIntegerParam (String name) {
String value = this.getParameter(name);
if (value == "") {
return 1;
}
try {
return Integer.parseInt(value);
} catch (Exception e) {
return 1;
}
}

private double getDoubleParam(String name) {
String value = this.getParameter(name);
if (value == "") {
return 0.0;
}
try {
return Double.valueOf(value).doubleValue();
} catch (Exception e) {
return 0.0;
}
}

public void actionPerformed(ActionEvent event) {
}

public void paint (Graphics g) {
g.drawOval(myXCenter+5-myUnit, myYCenter+5-myUnit, 2*myUnit-10, 2*myUnit-10);
g.drawString("C", myCat.getPosition().xCoord(myXCenter, myUnit)-5, myCat.getPosition().yCoord(myXCenter, myUnit)+5);
g.drawString("M", myMouse.getPosition().xCoord(myXCenter, myUnit)-5, myMouse.getPosition().yCoord(myYCenter, myUnit)+5);
g.drawString("Mouse at " + myMouse.getPosition() + "; cat at " + myCat.getPosition(), 50, ourWindowHeight-30);
g.drawString(statusString, 50, ourWindowHeight-15);
}

private Cat myCat;
private Mouse myMouse;
private boolean chaseIsOver = false;
private int timeElapsed;
private final int TIME_LIMIT = 30;

private Button nextStep;
private String statusString = "Not Yet Started.";
private final int BORDER = 50;
private static int ourWindowWidth, ourWindowHeight;
private int myXCenter, myYCenter, myUnit;
}

*** Position.java----------------------
public class Position {
public Position() {
myRadius = 0.0;
myAngle = 0.0;
}

public Position(Position p) {
myRadius = p.myRadius;
myAngle = p.myAngle;
}

public Position(double r, double theta) {
myRadius = r;
myAngle = theta;
}

public int xCoord(int xCenter, int unit) {
return xCenter + (int) (myRadius * Math.cos(myAngle) * unit);
}

public int yCoord(int yCenter, int unit) {
return yCenter + (int) (myRadius * Math.sin(myAngle) * unit);
}

public String toString() {
return "(" + myRadius + "," + myAngle + ")";
}

public void update(double rChange, double thetaChange) {
}

private double myRadius;
private double myAngle;
}

*** Cat.java------------------------
public class Cat {
public Cat() {
myPosition = new Position();
}

public Cat(Position p) {
myPosition = p;
}

public Position getPosition() {
return myPosition;
}

public boolean move(Position mousePosition) {
return true;
}

private Position myPosition;
}

*** Mouse.java-------------------------
public class Mouse {
public Mouse() {
myPosition = new Position();
}

public Mouse(Position p) {
myPosition = p;
}

public Position getPosition() {
return myPosition;
}

public void move() {
myPosition.update(0.0, 1.0);
}

private Position myPosition;
}
 
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have no idea what the parameters coming in are, specifically catradius, which is the one I'd suspect to be -1, it seems to be the only likely candidate for such an error, I would however expect you'd get something to this effect

java.lang.ArithmeticException: / by zero
at CatMouseChase.init(CatMouseChase.java:27)
at sun.applet.AppletPanel.run(AppletPanel.java:348)
at java.lang.Thread.run(Thread.java:536)


the line number would be different as I've added some logging info, also if the param is not passed in your getDoubleParam method catches a NullPointerException and returns zero, I'm not sure if thats the behaviour you wanted, but maybe consider changing your condition from

to

or

anyhat, hope that helps, only catradius being -1 could have caused this
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic