diff --git a/f.go b/f.go index c4f2b61..06c844c 100644 --- a/f.go +++ b/f.go @@ -9,7 +9,6 @@ import ( "math" "os" "sort" - "strconv" "strings" ) @@ -89,7 +88,7 @@ const HELP_MSG = " Operation | Variable assignment | Special\n" + " exit\n" const NORMAL90CONFIDENCE = 1.6448536269514727 const INIT_DIST Scalar = Scalar(1) -const N_SAMPLES = 100_000 +const N_SAMPLES = 1_000_000 /* Printers */ func prettyPrintDist(dist Dist) { @@ -305,7 +304,7 @@ func parseWordsIntoOpAndDist(words []string, vars map[string]Dist) (string, Dist return parseWordsErr("Operator must have operand; can't operate on nothing") case 1: var_word, var_word_exists := vars[words[0]] - single_float, err1 := strconv.ParseFloat(words[0], 64) // abstract this away to search for K/M/B/T/etc. + single_float, err1 := pretty.ParseFloat(words[0]) // abstract this away to search for K/M/B/T/etc. switch { case var_word_exists: dist = var_word @@ -315,16 +314,16 @@ func parseWordsIntoOpAndDist(words []string, vars map[string]Dist) (string, Dist return parseWordsErr("Trying to operate on a scalar, but scalar is neither a float nor an assigned variable") } case 2: - new_low, err1 := strconv.ParseFloat(words[0], 64) - new_high, err2 := strconv.ParseFloat(words[1], 64) + new_low, err1 := pretty.ParseFloat(words[0]) + new_high, err2 := pretty.ParseFloat(words[1]) if err1 != nil || err2 != nil { return parseWordsErr("Trying to operate by a distribution, but distribution is not specified as two floats") } dist = Lognormal{low: new_low, high: new_high} case 3: if words[0] == "beta" || words[0] == "b" { - a, err1 := strconv.ParseFloat(words[1], 64) - b, err2 := strconv.ParseFloat(words[2], 64) + a, err1 := pretty.ParseFloat(words[1]) + b, err2 := pretty.ParseFloat(words[2]) if err1 != nil || err2 != nil { return parseWordsErr("Trying to specify a beta distribution? Try beta 1 2") } diff --git a/pretty/pretty.go b/pretty/pretty.go index cf94ba8..1d823a5 100644 --- a/pretty/pretty.go +++ b/pretty/pretty.go @@ -60,7 +60,7 @@ func multiplyOrPassThroughError(a float64, b float64, err error) (float64, error } } -func parseFloat(word string) (float64, error) { +func ParseFloat(word string) (float64, error) { // l = len(word) // assuming no UTF stuff switch len(word) {