# ===----------------------------------------------------------------------=== #
# Copyright (c) 2026, Modular Inc. All rights reserved.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions:
# https://llvm.org/LICENSE.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===----------------------------------------------------------------------=== #
"""Provides functions for bit masks.

You can import these APIs from the `bit` package. For example:

```mojo
from std.bit.mask import is_negative
```
"""

from std.sys.info import bit_width_of


@always_inline
def is_negative(value: Int) -> Int:
    """Get a bitmask of whether the value is negative.

    Args:
        value: The value to check.

    Returns:
        A bitmask filled with `1` if the value is negative, filled with `0`
        otherwise.
    """
    return Int(is_negative(Scalar[DType.int](value)))


@always_inline
def is_negative[dtype: DType, //](value: SIMD[dtype, _]) -> type_of(value):
    """Get a bitmask of whether the value is negative.

    Parameters:
        dtype: The DType.

    Args:
        value: The value to check.

    Returns:
        A bitmask filled with `1` if the value is negative, filled with `0`
