No announcement yet.

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

  • Filter
  • Time
  • Show
Clear All
new posts

  • Thomas Gohel

    Hello Frank,

    here's some old PB/DOS code

    Best wishes,


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

    Leave a comment:

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

    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


    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))
    pi## = 4 * ATN(1)
    For X& = 1 to 18
    Pi$ = Str$(pi##, x&)
    Print Pi$
    Sorry, I don't know if you can calculate to better than 18 digits of precision using PowerBASIC..

    Rgds Dave