XANSYS Message: 85081 [Go back to message list]
No rating yet
Rate item:

Subject: Re: APDL: Problem with *voper,,,eq
Author: Winfried Schepers
Date: 2006-11-02 21:07:20

Rick,

your division by 1e6 will not re-introduce roundoff errors, since your
numbers have a binary integer representation with less than 48 digits.
Therefore Jürgens solutions works well.

However, the last line of your macro is a problem, because you are
comparing with a real constant, which in the binary system cannot be
represented exactly with a 48 bit mantissa as of double precision
variables. Play around with symbolic math software.

The binary representation of the exact decimal number 1.570796 is the
equivalent of the decimal number
1.570796000000000081087137004942633211612701416015625 (which in turn is
exactly 3,537,118,140,137,533/2,251,799,813,685,248). Now look at the
18th digit, it might get rounded to 1 at the 17th digit. As Jürgen said:
never compare real numbers for being exactly equal, in particular
literals, they mostly never are. If you really have to test a specific
value, you must first compute the accuracy of your software. Do this by
finding the smallest a, a being a negative power of 2, for which
numerically (1.+a)==1. For double precision numbers a=2**(-17). Then
compare a number b with a constant c using

*if,abs(b-c),lt,8*a,then
numbers are equal up to 45 binary digits
*else
numbers are not equal
*end

In Fortran90 the intrinsic function EPSILON was introduced, which yields
the number a!

Winfried SCHEPERS
Berlin University of Technology

rick.fischer_at_emersonnetworkpower.com schrieb:
>
> Thanks for the help Jurgen, Fern and Winfried. I expected rounding
> problems which is why I did the nint thing. Jurgen's suggestion to use
> 1570796 works for now, but are we saying that even though I ran it through
> the nint functionality that it is really still a floating point number
> with the possibility of non zeros out there to the right of the decimal
> point, or that the non zeros came back when I performed floating point
> math on it by dividing by1e6?
>

>
>

Posts possibly associated with message #85081AuthorDateScore
85055APDL: Problem with *voper,,,eqRick Fischer2006/11/02 
85057Re: APDL: Problem with *voper,,,eqFernand Thomassy2006/11/02 
85058Re: APDL: Problem with *voper,,,eqJürgen Humt2006/11/02 
85062Re: APDL: Problem with *voper,,,eqWinfried Schepers2006/11/02 
85063Re: APDL: Problem with *voper,,,eqYoshio Muki2006/11/02 
85065Re: APDL: Problem with *voper,,,eqFernand Thomassy2006/11/02 
85066Re: APDL: Problem with *voper,,,eqDave Lindeman2006/11/02 
85068Re: APDL: Problem with *voper,,,eqRick Fischer2006/11/02 
85069Re: APDL: Problem with *voper,,,eqRick Fischer2006/11/02 
85072Re: APDL: Problem with *voper,,,eqYoshio Muki2006/11/02 
85081Re: APDL: Problem with *voper,,,eqWinfried Schepers2006/11/02 
85083Re: APDL: Problem with *voper,,,eqRick Fischer2006/11/02 
85084Re: APDL: Problem with *voper,,,eqBram Weisman2006/11/02 
85088Re: APDL: Problem with *voper,,,eqJürgen Humt2006/11/03 
85089Re: APDL: Problem with *voper,,,eqWinfried Schepers2006/11/03 
85094Re: APDL: Problem with *voper,,,eqRick Fischer2006/11/03