Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/claygod/PiHex
PiHex Library, written in Go, generates a hexadecimal number sequence in the number Pi in the range from 0 to 10,000,000.
https://github.com/claygod/PiHex
Last synced: about 2 months ago
JSON representation
PiHex Library, written in Go, generates a hexadecimal number sequence in the number Pi in the range from 0 to 10,000,000.
- Host: GitHub
- URL: https://github.com/claygod/PiHex
- Owner: claygod
- License: other
- Created: 2016-07-22T11:21:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-10-18T19:22:54.000Z (about 2 months ago)
- Last Synced: 2024-10-25T05:24:50.653Z (about 2 months ago)
- Language: Go
- Size: 26.4 KB
- Stars: 20
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-go - PiHex - Implementation of the "Bailey-Borwein-Plouffe" algorithm for the hexadecimal number Pi. (Science and Data Analysis / HTTP Clients)
- zero-alloc-awesome-go - PiHex - Implementation of the "Bailey-Borwein-Plouffe" algorithm for the hexadecimal number Pi. (Science and Data Analysis / HTTP Clients)
- awesome-go - PiHex - PiHex Library, written in Go, generates a hexadecimal number sequence in the number Pi in the range from 0 to 10,000,000. - ★ 4 (Science and Data Analysis)
- awesome-go-extra - PiHex - 07-22T11:21:37Z|2022-06-27T18:21:50Z| (Science and Data Analysis / HTTP Clients)
- awesome-go-zh - PiHex
README
# PiHex
PiHex Library generates a hexadecimal number sequence in the number Pi in the range from 0 to 1.0e10000000. To calculate using "Bailey-Borwein-Plouffe" algorithm, instructions that was published by David H. Bailey September 17, 2006.[![API documentation](https://godoc.org/github.com/claygod/PiHex?status.svg)](https://godoc.org/github.com/claygod/PiHex)
[![Go Report Card](https://goreportcard.com/badge/github.com/claygod/PiHex)](https://goreportcard.com/report/github.com/claygod/PiHex)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/avelino/awesome-go)# Usage
An example of using the PiHex Library:
```go
package mainimport (
"fmt"
"github.com/claygod/PiHex"
)func main() {
pi := PiHex.New()
fmt.Print("The first 9 digits of Pi (hexadecimal): ", pi.Get(0, 9))
}
```# Settings
In the configuration file, you can change the constant STEP. This constant determines the amount generated in one step numbers. The reduction leads to a constant increase in the operating time of the program.
Attention! This constant can not be more than 9! Limitation due to the 64-bit library architecture.
The configuration file [config.go](https://github.com/claygod/PiHex/blob/master/ph_config.go)
# Perfomance
To optimize the run-time program, highly loaded sections of the library are performed in parallel (4 goroutines).
# API
Methods:
- *New* - create a new PiHex
- *Get* - receiving a sequence of hexadecimal digits starting at the specified position and in the right quantity.Example:
```go
pi := PiHex.New()
x := pi.Get(1000, 5)
```# Algorithm
The Bailey–Borwein–Plouffe formula (BBP formula) is a spigot algorithm for computing the nth binary digit of Pi using base 16 math. The formula can directly calculate the value of any given digit of π without calculating the preceding digits. The BBP is a summation-style formula that was discovered in 1995 by Simon Plouffe and was named after the authors of the paper in which the formula was published, David H. Bailey, Peter Borwein, and Simon Plouffe.
# Implementation
Plays Library is based on the publication "The BBP Algorithm for Pi" of David H. Bailey on September 17, 2006: http://www.davidhbailey.com/dhbpapers/bbp-alg.pdf
## Copyright
Copyright © 2017-2024 Eduard Sesigin. All rights reserved. Contacts: [email protected]