Re: Solving Triangles




"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx> wrote
in message news:A_CdnTueb8q_2kHeRVn-hA@xxxxxxxxxxxxxx
>
> It is not advisable to test the contents of a Double variable for equality
> to zero. Here is an example why...
> ...
> If Abs(Dx) < 1e-13 Then

Always worth it to raise that point.

In fact, the OP's code will throw a "divide by zero" error if Dx is 0:

> If Dx > 0 Then Bearing = (Atn(Dy / Dx) * DegConv) + 90
> If Dx < 0 Then Bearing = (Atn(Dy / Dx) * DegConv) + 270
>
> If Dx = 0 Then

So it would be better to rewrite the code
If Dx > 1E-13 then
Bearing =(Atn(Dy / Dx) * DegConv) + 90
ElseIf Dx < 1E-13 Then
Bearing = (Atn(Dy / Dx) * DegConv) + 270
ElseIf Dy < 1E-13
Then Bearing = 0
ElseIf Dy > 1E-13
Then Bearing = 180
Else
' not moving...
Bearing = 999.999
End If


.



Relevant Pages

  • Re: Validate textboxs with Form BeforeUdate
    ... Private Sub Form_BeforeUpdate ... Cancel = True ... "Zero Not Allowed" ... ElseIf Me.Textbox2.Value = 0 Then ...
    (microsoft.public.access.modulesdaovba)
  • Re: help regarding "if"
    ... zero or one is superior to two, which is seldom the case. ... elseif Oro_kvot>= 2 ...
    (comp.soft-sys.matlab)
  • Re: Use value of combo box column
    ... Combo box columns are indexed starting at zero, so the column numbers for a ... BTW, the condition must be on the same line as the ElseIf: ... Access Database Samples: www.rogersaccesslibrary.com ...
    (microsoft.public.access.formscoding)
  • preset range
    ... Rng = Selection.Rows.Count ... with 'the value zero ... ElseIf ActiveCell.Value = "Company" Then ... range of "A8:Z300" as the selection set. ...
    (microsoft.public.excel.programming)
  • Re: a very simple proof
    ... The ambiguity is whether the equality is true for a given value of x ... Counterexample 1) ... then f= gexcept on a set of measure zero. ... This is a consequence of the properties of equality. ...
    (sci.math)