Pixilang 3 floating point exception

Pixilang programming language
Post Reply
User avatar
FreeFull
Posts: 41
Joined: Fri Dec 10, 2010 11:42 am

Pixilang 3 floating point exception

Post by FreeFull »

Pixilang 3 on Linux x86

When I try to run the following code, Pixilang crashes with a Floating Point Exception:

Code: Select all

screen = get_screen()
SCRX = get_xsize(screen)
XSIZE = 256
YSIZE = XSIZE
TSIZE = XSIZE

x = 0
y = 0
t = 0

while( 1 ) {
	while( x<XSIZE ) {
		while( y<YSIZE ) {
			if(x%y)==t {
				screen[ y+(x*SCRX) ] = WHITE
			}
			else {
				screen[ y+(x*SCRX) ] = get_blend(screen[ y+(x*SCRX) ], BLACK, 30)
			}
			y = y + 1
		}
		y = 0
		x = x + 1
	}
	x = 0
	t = (t + 1) & (TSIZE-1)
	frame()
}
Pixilang doesn't crash if I replace if(x%y)==t with something like if(x^y)==t

Here is the console output:

Code: Select all

SunDog Engine / Sep  1 2011
MAIN: device start
MAIN: screen_angle = 0
MAIN: screen_zoom = 1
MAIN: screen_xsize = 320
MAIN: screen_ysize = 240
MAIN: system palette init
MAIN: wmanager initialized
ALSA: pulse
ALSA HW Sample rate: 44100
ALSA HW Buffer size: 8192 frames
ALSA HW Period size: 221
ALSA HW Periods: 0
ALSA SW Avail min: 221
ALSA SW Start threshold: 1
ALSA SW Stop threshold: 8192
Floating point exception
User avatar
NightRadio
Site Admin
Posts: 3944
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Pixilang 3 floating point exception

Post by NightRadio »

It is normal behaviour :)
In the first step x = 0, y = 0. And you trying to execute 0%0 operation, which is not allowed. Also you will get the same result, if you will try to divide by zero: x div 0
User avatar
FreeFull
Posts: 41
Joined: Fri Dec 10, 2010 11:42 am

Re: Pixilang 3 floating point exception

Post by FreeFull »

Oh, I see. This didn't happen in 1.6, so I thought there was something wrong. Thanks!
User avatar
NightRadio
Site Admin
Posts: 3944
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Pixilang 3 floating point exception

Post by NightRadio »

1.6 allowed devide by zero :) But i removed this "feature" in 3.0.
Post Reply