Skip to content

Bikeshedding: BigInt.sqrt/cbrt vs. BigInt.isqrt/icbrt #26

Open
@js-choi

Description

@js-choi

Most programming languages that include the integer square root use the name isqrt instead of sqrt. Some of them do use sqrt for integer square roots.

  • isqrt in generic namespace: Common Lisp, Crystal, Julia, Maple, PARI/GP*, Python, Racket*, SageMath, Scheme*, Tcl
  • isqrt in integer namespace/class: Rust
  • sqrt in integer namespace/class: Chapel, Java, Ruby, Zig

(Languages marked with * spell out isqrt using words like integer-sqrt.)

Notably, if we name the BigInt root functions BigInt.isqrt/icbrt instead of BigInt.sqrt/cbrt, then this would point towards also including a Math.isqrt/icbrt for numbers.

  • Should we name the BigInt root functions BigInt.sqrt/cbrt vs. BigInt.isqrt/icbrt?
  • If we do go with BigInt.isqrt/icbrt, then, in a future proposal (not this one), should we consider Math.isqrt/icbrt for numbers?

I would personally like integer square roots to consistently be isqrt across both bigints (BigInt.isqrt) and numbers (Number.isqrt). If integer square roots are useful on bigints, then they'd be useful on integer numbers too.

CC: @bakkot, @waldemarhorwat, @ljharb

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions