Announcement

Collapse
No announcement yet.

Re: 'Code Wanted: Calculate Pi in PB_DOS' from Source Code Forum

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

  • Thomas Gohel
    replied


    Hello Frank,

    here's some old PB/DOS code
    http://www.pbhq.de/filebase/fdb110.html#CALC-PI.BAS


    Best wishes,

    Thomas

    ## Mozilla/5.0 (Windows; U; Win98; de-DE; rv:1.0.2) Gecko/20030208 Netscape/7.02 Hamster/2.0.5.5, via PBNEWS v0.45g (news.pbhq.de)

    Leave a comment:


  • Tom Hanlin
    replied
    The LONGPI code for PB/Win can probably be translated...

    http://powerbasic.com/files/pub/pbwin/misc/

    ------------------
    Tom Hanlin, PowerBASIC Staff
    Opinions expressed may not be those of my employer or myself

    Leave a comment:


  • Re: 'Code Wanted: Calculate Pi in PB_DOS' from Source Code Forum

    Original question posed in the Source Code forum..
    Greetings ...

    Would someone please be kind enough to post a simple Pi calculation code using PB-DOS?

    Specificly, I desire to see code where variable X equals number of places that Pi is to be carried to - be it 10, 100, 707 or whatever!

    ------------------
    Thanx-A-Lot and Enjoy, Frank -- My PB
    ------------------

    Frank,

    Here is some text snipped from PB's docs:
    Pi is a transcendental constant, meaning that it has an infinite number of decimal places.
    To 15-place accuracy, adequate for most applications, p = 3.141592653589793##.
    This value can be closely approximated with the expression:
    pi## = 4 * ATN(1)
    ..
    The ATN function always returns an Extended-precision result.
    ..
    Extended-precision values require 10 bytes of storage each.
    They have a range of approximately +/- 3.4x10^-4932 to 1.2x10^4932,
    and offer 18 digits of precision. All 18 digits can be "displayed" using
    the extended STR$ format (eg, STR$(var##,18))
    eg.
    Code:
    pi## = 4 * ATN(1)
    For X& = 1 to 18
    Pi$ = Str$(pi##, x&)
    Print Pi$
    next
    Sorry, I don't know if you can calculate to better than 18 digits of precision using PowerBASIC..

    Rgds Dave

    ------------------
Working...
X