package
0.0.0-20250206101203-bd6683890685
Repository: https://github.com/dockerian/go-coding.git
Documentation: pkg.go.dev
# Functions
Compare returns 0 if a == b; 1 if a > b; or -1 if a < b.
EqualSign checks if a and b are both same signed (positive or negative) NOTE: - same sign: a^b >= 0 - opposite sign: a^b < 0.
Fibo returns fibonacci number: F(n) = F(n-1) + F(n-2).
Fibos returns fibonacci numbers sequence.
GaussSum calculates sum of a series of integers from specific `start` with an `interval` in next `num` sequence (as total `num + 1`).
IsSquareRootInteger returns true if square root of num is integer.
LogBaseX caculates base log of x Note: Log <base> (x) = Log(x) / Log(base).
MaxAndMin returns maximum and minimum integers from v ...int.
MaxAndMinInt16 returns maximum and minimum 16-bit integers from v ...int.
MaxAndMinInt32 returns maximum and minimum 32-bit integers from v ...int.
MaxAndMinInt64 returns maximum and minimum 64-bit integers from v ...int.
MaxAndMinInt8 returns maximum and minimum 8-bit integers from v ...int.
MaxInt returns maximum int from v ...int.
MinInt returns minimum int from v ...int.
ModularExponent calculates (x^y)%p based on fomular ``` (a * b) % p == ((a % p) * (b % p)) % p ``` as such reducing the chance of overflow.
MultiplyUint64 gets muliplication of two integers.
NearEqual compares a and b in range of precision See: - https://www.socketloop.com/tutorials/golang-compare-floating-point-numbers - https://floating-point-gui.de/errors/comparison/.
ParseInt64 converts a string to integer, assuming base-10.
Power calculates (x ^ y) in O(log n).
RandRangeFloat64 returns a pseudo-random float64 in [min,max).
RandRangeInt64 returns a pseudo-random int64 in [min,max).
ReverseInt64 reverses a decimal integer.
Sqrt calculates square root of x (to demonstrate float point comparison).
SumUint64 gets sum of two integers.
SwapInt swaps two integers.
# Constants
MAXINT represents maximum int.
int(MAXUINT16 >> 1).
int(MAXUINT32 >> 1).
int64(MAXUINT64 >> 1).
int(MAXUINT8 >> 1).
MAXUINT represents maximum uint.
MAXUINT16 represents maximum 16-bit unsigned integer.
MAXUINT32 represents maximum 32-bit unsigned integer.
MAXUINT64 represents maximum 64-bit unsigned integer.
MAXUINT8 represents maximum 8-bit unsigned integer.
MININT represents minimum int.
^MAXINT16.
^MAXINT32.
^MAXINT64.
^MAXINT8.
Precision set precision for math functions.
# Variables
Fibonacci lookup table.