Division by zero - what happens

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
blackcattech
Posts: 113
Joined: Mon Jan 11, 2010 10:39 pm
Location: Chesterfield

Division by zero - what happens

Post by blackcattech » Fri Apr 05, 2013 11:31 am

I can't spot anything in the help files on this, what is the result if you try and divide a float by zero in Swordfish? Does it just automatically set the result to the maximum value a float can hold, or could the result be undefined? I'm not sure if it is worth doing a separate test for when this can happen of if Swordfish deals with it automatically?

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Fri Apr 05, 2013 11:58 am

undetermined - you should always code accordingly, that is, your program should always check for zero your "divide by" value if there is any possibility of it being zero. This rule should be applied to pretty much all programming languages, not just Swordfish.

Post Reply