Skip to content

IntTryLog2

Description

Try to compute floor(log2(value)).

Success

Returns true. The result has been computed and the destination object updated.

Failure

Returns false when value is zero. The destination is left untouched.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool IntTryLog2(const Int *value, u64 *out) {
        if (!value || !out) {
            LOG_FATAL("Invalid arguments");
    u64 IntLog2WithError(const Int *value, bool *error) {
        u64  out = 0;
        bool ok  = IntTryLog2(value, &out);
    
        if (error) {
        u64 max_degree = 0;
    
        if (!IntTryLog2(value, &max_degree)) {
            return false;
        }
Last updated on