There is probably a better way, but lets start with a clear definition of the problem. Your post says you want to "round *down*" but the variable 'bet' is the result of a divide by 4, rounded *up*. Which do you actually want to do?
On Sunday, August 2, 2020 at 5:09:45 PM UTC-4 traxp...@gmail.com wrote: > I have written my first little piece of Go-code. > However it took some time and code for me to divide a int64 by 4 and round > down. > > How can the last two lines be rewritten? > > Regards > Martin > > package main > > import ( > "fmt" > "bufio" > "math" > ) > > > var cash int64 > scanner := bufio.NewScanner(os.Stdin) > > scanner.Scan() > cash,err = strconv.ParseInt(scanner.Text(), 10, 64) > if err != nil { > fmt.Println(err) > } > > var bet int64 > bet = int64(math.Ceil(float64(cash)/float64(4))) > cash = cash - bet > > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/9858e40e-454e-4700-8556-83f5e3c0ec08n%40googlegroups.com.