Initial commit: Pi calculation benchmark with 34 languages
- Added implementations for: bash, brainfuck, c, cpp, crystal, csharp, d, dart, elixir, erlang, fortran, go, haskell, java, javascript, julia, kotlin, objective-c, scala, typescript, lua, nim, odin, perl, php, python, r, ruby, rust, swift, zig, assembly, vimscript, wolfram - All implementations use Machin's formula: π/4 = 4*arctan(1/5) - arctan(1/239) - Build system with ./build.sh, test system with ./test.sh - Performance testing with ./run_all.sh - Comprehensive README.md explaining performance differences - Test framework verifies correctness against known π values
This commit is contained in:
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Beräknar pi med angivet antal decimaler
|
||||
# Användning: print_hej <antal_decimaler>
|
||||
|
||||
decimals=${1:-100}
|
||||
# bc behöver scale = decimals + några extra för korrekt avrundning
|
||||
# Ta bort backslash från utmatningen
|
||||
echo "scale=$((decimals + 5)); 4*a(1)" | bc -l | tr -d '\\\n' | head -c $((decimals + 2))
|
||||
echo
|
||||
Reference in New Issue
Block a user