hpcalc2

package
v0.0.0-...-30f5a02 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: GPL-3.0, LGPL-2.1 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	X = iota // StackRegNames as int.  No need for a separate type.
	Y
	Z
	T5
	T4
	T3
	T2
	T1
	StackSize
)
View Source
const Bottom = X
View Source
const HeaderDivider = "+-------------------+------------------------------+"
View Source
const LastAlteredDate = "3 Apr 2026"
View Source
const PI = math.Pi // 3.141592653589793;
View Source
const SpaceFiller = "     |     "
View Source
const Top = T1

Variables

View Source
var CurUndoRedoIdx int
View Source
var LastX, MemReg float64
View Source
var StackRegNamesString = []string{" X", " Y", " Z", "T5", "T4", "T3", "T2", "T1"}
View Source
var StackUndoMatrix []StackType

Functions

func AddCommas

func AddCommas(instr string) string

func CropNStr

func CropNStr(instr string) string

func DumpStackFixed

func DumpStackFixed() []string

DumpStackFixed -- Returns a slice of stack strings in fixed point format.

func DumpStackFloat

func DumpStackFloat() []string

DumpStackFloat -- returns a slice of strings that were converted from float64 to string using FormatFloat.

func DumpStackGeneral

func DumpStackGeneral() []string

DumpStackGeneral -- Dumps the stack using a general format verb.

func Floor

func Floor(real, places float64) float64

Floor -- To automatically fix the small floating point errors introduced by the conversions. Real can be negative, places cannot be negative or > 10.

func GCD

func GCD(a, b int) int

GCD means greatest common divisor, which is a synonym for HCF

func GetRegIdx

func GetRegIdx(chr byte) int

func GetResult

func GetResult(s string) (float64, []string)

GetResult -- Input a string of commands and operations, return the result as a float64 and a message as a slice of strings.

func HCF

func HCF(a, b int) int

HCF means highest common factor.

func InsertIntoByteSlice

func InsertIntoByteSlice(slice, insertion []byte, index int) []byte

func IsPrime

func IsPrime(real float64) bool

IsPrime -- Just what its name says.

func MakeSubst

func MakeSubst(instr string) string

MakeSubst -- Now uses a strings replace function.

func MapWriteAndClose

func MapWriteAndClose()

func NextPrimeFac

func NextPrimeFac(n, startfac uint) (uint, bool)

NextPrimeFac -- Returns the next prime factor after the given one. Supports the memoization algorithm. Returns true when returning a prime factor. False means there are no more prime factors.

func OutputFixedOrFloat

func OutputFixedOrFloat(r float64)

OutputFixedOrFloat -- Tries to output a number without an exponent, if possible. Will output an exponent if it has to.

func PUSHX

func PUSHX(R float64)

func PWRI

func PWRI(R float64, I int) float64

PWRI -- Power function that multiplies the minimum number of times. Exponent is an int that can be negative. Power Of I. This is a power function with a real base and integer exponent, using the optimized algorithm as discussed in PIM-2, V 2.

func PopX

func PopX() float64

func PrimeFactorMemoized

func PrimeFactorMemoized(U uint) []uint

PrimeFactorMemoized -- returns a slice of uint prime factors using a memoization algorithm.

func PushMatrixStacks

func PushMatrixStacks()

PushMatrixStacks -- Saves the stack state prior to an operation that will change the stack state.

func READX

func READX() float64

func RedoMatrixStacks

func RedoMatrixStacks()

RedoMatrixStacks -- Redo the stack matrix, that is, undo the undo by reverting to a later stack state. Need to increment the pointer first, twice.

func Result

func Result(tkn tknptr.TokenType) (float64, []string)

func Round

func Round(f float64) float64

func STACKDN

func STACKDN()

func STACKROLLDN

func STACKROLLDN()

func STACKUP

func STACKUP()

func SWAPXY

func SWAPXY()

func SetSigFig

func SetSigFig(sf int)

func SigFig

func SigFig() int

func ToHex

func ToHex(L float64) string

ToHex -- Uses an elegant algorithm I recently read about.

func UndoMatrixStacks

func UndoMatrixStacks()

UndoMatrixStacks -- performs an undo operation by reverting to a previous stack state.

Types

type StackType

type StackType [StackSize]float64
var Stack StackType

func GETSTACK

func GETSTACK() StackType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL