Skip to content

Instantly share code, notes, and snippets.

@andreafioraldi
Created April 27, 2017 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreafioraldi/a5fc7b86201babf7f904764e84397e2d to your computer and use it in GitHub Desktop.
Save andreafioraldi/a5fc7b86201babf7f904764e84397e2d to your computer and use it in GitHub Desktop.
Calculate PI using my own programming language: Stout
/*
Calculate PI using my own programming language: Stout
author = Andrea Fioraldi
copyright = Copyright 2017, Andrea Fioraldi
license = MIT
mail = andreafioraldi@gmail.com
*/
use IO;
use Math;
if(args.Length() < 3) {
IO.PrintErr("Usage: ./calculate_pi.dubbel <precision:int> <output_file:string>\n");
return 1;
}
try precision <- args[1].ToInt();
catch {
IO.PrintErr("The precision argument must be an integer\n");
return 1;
}
output <- args[2];
pi <- Math.GetPI(precision);
try file <- new IO.File(output, "w");
catch {
IO.PrintErr("Invalid file ", output, "\n");
return 1;
}
file.Write(pi);
file.Close();
IO.Printl("Done.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment