Announcement

Collapse
No announcement yet.

Search the formula of Degrees

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Eric Pearson
    replied
    Aldo --

    There's no reason to get upset...

    It could be argued that using an asm function to obtain a known, fixed value is less efficient -- and no more accurate -- than hard-coding the number. A numeric constant with the ## suffix is just as accurate as any other extended-precision value. So if PB did decide to implement a PI function, it seems likely that they would skip all of the code that would be required to detect the FPU and simply hard-code the value.

    I agree that it would be convenient to have a keyword PI that corresponded to 3.14159... but the only thing it would really accomplish would be to save the programmer some typing. PowerBASIC For Windows 7.0 and 3.0 users can easily create a MACRO called PI, so perhaps it would be more productive to suggest that MACROs be added to the next version of PB/DOS, to kill many birds with one stone.

    -- Eric


    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Lance Edmonds
    replied
    Aldo, please don't get upset or ticked off -- that was _not_ my intention (hence the presence of the smiley-face icon).

    I was simply pointing out a stumbling block with implementing that specific ASM code, and that it is theoretically possible for you to implement it yourself with the current version of the compiler.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Aldo Cavini
    replied
    Since the compiler has the $FLOAT metastatement, I thought it used the FPU if present. On the other hand, I think a function to get the PI value can be emulated also... well, the idea was to have a function to automatically get the PI value. Sorry to have told the PB staff what I liked to add to the wish list - or, worse of all, to have told how it could be implemented.

    ALdo

    ------------------

    Leave a comment:


  • Jerry Mason
    replied
    FLDPI is a numeric coprocessor command - you have to have a
    coprocessor installed or built into your processor (486DX and later).
    Please don't assume that everyone using PB/DOS has one!


    ------------------

    Leave a comment:


  • Lance Edmonds
    replied
    FLDPI... is that available on _all_ x86 platforms? (PB/DOS is used in embedded XT-class machines, so 8086 compatibility is still a requirement).

    In any case, you might be able to do it yourself with the appropriate use of the !DB statement.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Aldo Cavini
    replied
    The best way I know to get the exact value of PI (any version of basic) is:
    Code:
    pi = 4 * atn( 1 )
    hence
    Code:
    degrees = radians * 180 / pi
    and
    Code:
    radians = degrees * pi / 180
    If you use extended precision, you'll get very accurate results.

    A question to the PB staff. Why not to add a pseudo-function to get the PI value? It could use the FLDPI assembler instruction, which I think is the fastest way to manage the PI value. It is only an idea, but it could be added to the wish list.

    ------------------


    [This message has been edited by Aldo Cavini (edited June 27, 2002).]

    Leave a comment:


  • Michael Mattias
    replied
    * %PI
    You are going to have a heck of a time if PI (=3.14159265 or so) is restricted to an integer range, as PB equates are..

    As far as converting degrees to radians, there are 2*pi radians in 360 degrees. But you learned that in high school.

    MCM


    Leave a comment:


  • Eric Pearson
    replied
    Code:
    FUNCTION Deg2Rad(BYVAL dpDegrees AS DOUBLE) AS DOUBLE
        FUNCTION = dpDegrees * 0.0174532925199433#
    END FUNCTION               
     
    FUNCTION Rad2Deg(BYVAL dpRadians AS DOUBLE) AS DOUBLE
        FUNCTION = dpRadians *  57.29577951308232#
    END FUNCTION
    -- Eric


    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Stephane Fontaine
    Guest started a topic Search the formula of Degrees

    Search the formula of Degrees

    Hey All

    Can someone help me if this functions corrected is?

    FUNCTION Deg2Rad(xg AS SINGLE) AS SINGLE
    FUNCTION = xg * %PI / 180
    END FUNCTION

    FUNCTION Rad2Deg(xr AS SINGLE) AS SINGLE
    FUNCTION = xr * %PI / 57
    END FUNCTION


    Can anybody help me how I can write an function for convert radians to
    degrees?

    Kind regards


    ------------------
    Brainsoft Programmers
Working...
X