BBC BASIC for Windows
« Division by zero! »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:44pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Division by zero!  (Read 360 times)
Ric
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 136
xx Division by zero!
« Thread started on: Aug 27th, 2016, 8:39pm »

I have come across an annoying problem. When trying to calculate an angle using ATN I get a divide by zero error. I know that the error is correct because the second variable is zero, but surely the code should return 90degrees.

angle=ATN(var1/var2)

If var2=0 then the error occurs. I know that what is in the brackets is a division by zero, but how do I get round this problem?

Ric

Sorry, forgot to say
var1 is the opposite and
Var2 is the adjacent.

They are always changing.

P.S. I'd rather not solve it by error trapping or testing for zero.
« Last Edit: Aug 28th, 2016, 09:01am by Ric » User IP Logged

It's always possible, but not necessarily how you first thought. Chin up and try again.
sbracken
New Member
Image


member is offline

Avatar




PM


Posts: 19
xx Re: Division by zero!
« Reply #1 on: Sep 7th, 2016, 12:53pm »

Given the error is inevitable when var2 is zero, you are going to have to have some sort of error trapping or testing to catch it.

As always, Richard is one step ahead:

https://bb4w.wikispaces.com/The+ATAN2+function

Simon
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls