Bend icon indicating copy to clipboard operation
Bend copied to clipboard

Divide by zero error without dividing by zero

Open Gadersd opened this issue 9 months ago • 1 comments

I get the following error message on bend version 0.2.7 running with bend run test.bend

attempt to divide by zero
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
exit status: 101

The error is caused by

def normalize_coord(coord, width, height):
  (x, y) = coord
  return ( x / width, y / height)

However, width and height are never zero. Rewriting as

def normalize_coord(coord, width, height):
  (x, y) = coord
  return ( x / 4, y / 4)

yields no error. The full code is test.zip

Gadersd avatar May 18 '24 23:05 Gadersd