math.big: rework function naming and documentation#18890
math.big: rework function naming and documentation#18890medvednikov merged 5 commits intovlang:masterfrom
Conversation
|
Most builtin types support a In the same vein, the other |
|
Oh okay, I only knew about |
|
The builtin types don't have a So... as long as the name makes sense, it should be fine. Bytes do have an extra method... |
|
|
|
@hungrybluedev thoughts on |
Seems fine as long as we include the full word “binary” in the documentation somewhere. People should be able to find it through page search. |
Overview
A few functions are renamed to allow for a more extensible, legible and standardized scheme; i.e. mathematical functions (
isqrt,gcd, ...) remain as they are, however methods such asleft_shiftandright_shiftare changed to be more verbose and clear -- allowing futureleft_rotateandright_rotatemethods (more legible than e.g.rrotate). The renaming oflshiftandrshiftis applied internally as well for consistency.The function
bit_lengthis deprecated as it seems to have been made public by accident in math.big: Improve multiplication performance #15200. Instead use ofbit_lenis encouraged.Renaming is also done in
big.js.vto better fit the naming of the rest of the module; warranting deprecation of renamed functions.In the base arithmetic operations the first operand is also renamed to match their respective formal names (see this discussion on math.stackexchange).
Documentation is adjusted in certain situations where the declared operand name does not match the documented name. Missing documentation for overridden arithmetic operators is also added for clarity.
Notes
isqrtmust remain un-renamed, so as to not be mixed up with a future decimal precision return type function, which shall be namedsqrt.incanddecare common enough to be left alone in this PR.absandnegare common short forms of absolute values and negations, therefore they remain as they are.bitwise_*methods may warrant further discussion in this PR.binary_str,hexandradix_strshould be discussed for a general scheme, such asbin_str,hex_strandradix_strbeing longer to be visually better separated from the predetermined bases.🤖 Generated by Copilot at 075a6a1
This pull request renames several functions and parameters in the
math/bigmodule to improve clarity, consistency, and readability. It also adds deprecated annotations and wrapper functions for the old names to ensure backward compatibility. The changes affect the filesbig_test.v,big.js.v,division_array_ops.v,exponentiation.v,integer.v,special_array_ops.v, and their corresponding test files.🤖 Generated by Copilot at 075a6a1
lshiftandrshiftfunctions toleft_shiftandright_shiftfor clarity and consistency withIntegermethods (link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link)divmodfunction todiv_modto follow snake_case convention and be consistent withIntegermethod of the same name (link,link)b_and,b_or, andb_xorfunctions tobitwise_and,bitwise_or, andbitwise_xorfor descriptiveness and consistency withIntegermethods of the same names (link,link,link)factfunction tofactorial_intfor descriptiveness and consistency withfactorialfunction that takes aNumberargument (link)