mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
math: new consts + helpers funcs for string to int / float
This commit is contained in:

committed by
Alexander Medvednikov

parent
5cd38ec91b
commit
b32a462b2e
@ -10,39 +10,6 @@ module math
|
||||
// When adding a new function, please make sure it's in the right place.
|
||||
// All functions are sorted alphabetically.
|
||||
|
||||
const (
|
||||
e = 2.71828182845904523536028747135266249775724709369995957496696763
|
||||
pi = 3.14159265358979323846264338327950288419716939937510582097494459
|
||||
phi = 1.61803398874989484820458683436563811772030917980576286213544862
|
||||
tau = 6.28318530717958647692528676655900576839433879875021164194988918
|
||||
|
||||
sqrt2 = 1.41421356237309504880168872420969807856967187537694807317667974
|
||||
sqrt_e = 1.64872127070012814684865078781416357165377610071014801157507931
|
||||
sqrt_pi = 1.77245385090551602729816748334114518279754945612238712821380779
|
||||
sqrt_tau = 2.50662827463100050241576528481104525300698674060993831662992357
|
||||
sqrt_phi = 1.27201964951406896425242246173749149171560804184009624861664038
|
||||
|
||||
ln2 = 0.693147180559945309417232121458176568075500134360255254120680009
|
||||
log2_e = 1.0 / ln2
|
||||
ln10 = 2.30258509299404568401799145468436420760110148862877297603332790
|
||||
log10_e = 1.0 / ln10
|
||||
)
|
||||
|
||||
const (
|
||||
max_i8 = 127
|
||||
min_i8 = -128
|
||||
max_i16 = 32767
|
||||
min_i16 = -32768
|
||||
max_i32 = 2147483647
|
||||
min_i32 = -2147483648
|
||||
// MaxI64 = ((1<<63) - 1)
|
||||
// MinI64 = (-(1 << 63) )
|
||||
max_u8 = 255
|
||||
max_u16 = 65535
|
||||
max_u32 = 4294967295
|
||||
max_u64 = 18446744073709551615
|
||||
)
|
||||
|
||||
// Returns the absolute value.
|
||||
pub fn abs(a f64) f64 {
|
||||
if a < 0 {
|
||||
|
Reference in New Issue
Block a user