Hacker News new | ask | show | jobs
by all2 1335 days ago
I don't program C or Go. I ran the logic and it works; I verified by running a modified version of this method on my computer.

    func below(n int) {
        for n--; n >= 0; n-- {
            fmt.Println(n)
        }
    }
I modified the type so I could punch in some sane integer, like 4. And this works.

    C:\git\bugfix66> go run .\bugfix66-2.go
    3
    2
    1
    0
Am I to assume that the bug is actually a type issue? Something to do with unsigned integers?

Wait. Oh. Ok. I get it. It does have to do with the type signature.

2 comments

What happens if you start at n=0 for uint64?

(my real comment after I get some clarification from the bugfix site author is that I never, ever modify a variable in the initialization condition of a for loop, and i see that in the wild, I elide it.

You're using a signed integer.