Skip to content

handle round() with ndigits argument#39

Merged
medvednikov merged 1 commit intovlang:masterfrom
ylluminate:fix-round-ndigits
Feb 20, 2026
Merged

handle round() with ndigits argument#39
medvednikov merged 1 commit intovlang:masterfrom
ylluminate:fix-round-ndigits

Conversation

@ylluminate
Copy link
Contributor

Python's round(x, ndigits) was dropping the second argument, producing math.round(x) instead of preserving decimal-place precision. round(3.14159, 2) produced 3.0 instead of 3.14.

Changes

  • visit_round() in plugins.v: Dispatch on args.len — two-argument form uses math.round_sig(x, ndigits), single-argument form is unchanged
  • 1 test expected output updated (abs_round)

All 108 tests pass (0 skipped).

Python's round(x, ndigits) was dropping the second argument,
producing math.round(x) instead of preserving decimal-place
precision. round(3.14159, 2) produced 3.0 instead of 3.14.

Uses math.round_sig(x, ndigits) for the two-argument form.
Single-argument round(x) is unchanged.

- visit_round() in plugins.v: dispatch on args.len for ndigits
- 1 test expected output updated (abs_round)

All 108 tests pass.
@medvednikov medvednikov merged commit a1e8653 into vlang:master Feb 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants