/
Scnd_F.Shortcuts.go
71 lines (65 loc) · 1.84 KB
/
Scnd_F.Shortcuts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package Firefly_Precision
import "math/big"
//
// Scnd_F.Shortcuts.go Secondary Function Shortcuts
//
//================================================
// Function List:
//
// 01 - NFS new from string
// 02 - NFI new from integer
// 03 - INT64 decimal to int64
//
//================================================
// Shortcuts functions of Main Functions
// Eases up function usage, discarding the Condition and Error outputs
//
//================================================
//
// Function 01 - NFS
//
// NFS creates a new decimal from a string s.
// Same as NewFromString, it only outputs the decimal
// It has no restriction on precision. Tested Accepted characters are "." and "-" for a negative sign
func NFS(s string) *Decimal {
d := new(Decimal)
//Further Tests can be added to detect wrong string construction.
//It is always assumed the string number used with this function is of correct construction.
d, _, _ = NewFromString(s)
return d
}
//================================================
//
// Function 02 - NFI
//
// NFI creates a new decimal from a string integer
// THe integer must be within int64 range
// From -9,223,372,036,854,775,808 to
// 9,223,372,036,854,775,807
func NFI(coeff int64) *Decimal {
d := new(Decimal)
d = New(coeff, 0)
return d
}
//================================================
//
// Function 03 - NFBI
//
// NFBI creates a new decimal from a big.Int number
func NFBI(Number *big.Int) *Decimal {
d := new(Decimal)
d = NewWithBigInt(Number, 0)
return d
}
//================================================
//
// Function 04 - INT64
//
// INT64 returns the int64 representation of x.
// No error is returned with this function
func INT64(Decimal2Convert *Decimal) int64 {
var Result int64
Result, _ = Decimal2Convert.Int64()
return Result
}
//================================================