Division by Zer0

1. Senior Member
Join Date
Dec 1969
Posts
2,238

## Division by Zer0

Will I have a problem with this psuedo code in regards to dividing by zero?<BR><BR> CallRate = rs("PR_Rating")<BR><BR>&#039; ***/// START THE MATH \***<BR>&#039; the true rating is the current point total in PR_Rating divided by PR_VoteCount<BR>&#039; right now that is 0 and 0 respectively<BR><BR>Thanks,<BR>Daniel

2. Senior Member
Join Date
Dec 1969
Posts
2,809

## Yup...

I&#039;m pretty sure you&#039;ll get an error if you try to divide by zero.

3. Senior Member
Join Date
Dec 1969
Posts
2,238

## RE: Yup...

CallRate = rs("PR_Rating")<BR> VoteCount = rs("PR_VoteCount")<BR><BR>&#039; ***/// START THE MATH \***<BR>&#039; the true rating is the current point total in PR_Rating divided by PR_VoteCount<BR>&#039; right now that is 0 and 0 respectively<BR>CallRate = CallRate VoteCount<BR>Response.Write CallRate<BR><BR>How can I work around the records that are 0 and 0?<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
2,238

Is this the best answer?<BR><BR>If CallRate &#060;&#062; 0 Then<BR>CallRate = CallRate VoteCount<BR>Else<BR>CallRate = 0<BR>End If<BR>Response.Write CallRate

5. Senior Member
Join Date
Dec 1969
Posts
2,809

## RE: Yup...

Basically, you just have to check for votecount. the numerator can be zero, it won&#039;t error out. <BR><BR>If votecount = 0 Then<BR> &#039;Crapola. Can&#039;t divide by zero. <BR>Else<BR> CallRate = CallRate VoteCount<BR>End If

6. Senior Member
Join Date
Dec 1969
Posts
2,238

## Ok THanks! <eop>

.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•