MCPcopy Create free account
hub / github.com/Pallinder/go-randomdata / Decimal

Function Decimal

random_data.go:247–261  ·  view source on GitHub ↗
(numberRange ...int)

Source from the content-addressed store, hash-verified

245}
246
247func Decimal(numberRange ...int) float64 {
248 nr := 0.0
249 if len(numberRange) > 1 {
250 nr = 1.0
251 nr = privateRand.Float64()*(float64(numberRange[1])-float64(numberRange[0])) + float64(numberRange[0])
252 } else {
253 nr = privateRand.Float64() * float64(numberRange[0])
254 }
255
256 if len(numberRange) > 2 {
257 sf := strconv.FormatFloat(nr, 'f', numberRange[2], 64)
258 nr, _ = strconv.ParseFloat(sf, 64)
259 }
260 return nr
261}
262
263func StringNumberExt(numberPairs int, separator string, numberOfDigits int) string {
264 numberString := ""

Callers 2

TestDecimalFunction · 0.85
ExampleRandomdataFunction · 0.85

Calls 1

Float64Method · 0.80

Tested by 2

TestDecimalFunction · 0.68
ExampleRandomdataFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…