# std.math.isPowerOfTwo: add tests and doc comment and improve assert · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/2839e35d1c06ca5b6bda1f20ae870f2b2fbbbfb1)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 2839e35d1c06ca5b6bda1f20ae870f2b2fbbbfb1

Requested commit: 2839e35d1c06ca5b6bda1f20ae870f2b2fbbbfb1

Commit: 2839e35d1c06ca5b6bda1f20ae870f2b2fbbbfb1

Tree: e563096f2b145f0edbc6e556b43284d5fd006582

Author: r00ster91

Committer: Andrew Kelley

## Message

```
std.math.isPowerOfTwo: add tests and doc comment and improve assert

The assert is changed from `int != 0` to `int > 0` because negative
integers always return `false`.
Python's `math.log2` does the same and errors for 0 or negative integers.

```

## Parents

- [c13ac52972b864ff3aa9fc373f96d7ede41d5a31](https://git.cafe/gitcafe/zig/commit/c13ac52972b864ff3aa9fc373f96d7ede41d5a31?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/2839e35d1c06ca5b6bda1f20ae870f2b2fbbbfb1?format=markdown)
