Skip to content

add .bit_length() method to Integer #33676

@yyyyx4

Description

@yyyyx4

Python has int.bit_length(), but Sage has Integer.nbits().

In this patch, we add Integer.bit_length() for compatibility with int.

Among other things, this change should make it easier to switch from Python to Sage mid-development, which currently requires replacing all calls to .bit_length() or adding casts to int.

This helps with

Component: basic arithmetic

Author: Lorenz Panny

Branch: fb8f165

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/33676

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions