Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 00ca79a1836b6e3b922fe09dc5deef4ab0028b0ef5f4bbd6ca59e42d19f72ea7
Ticket: bd71dd33055d27d7fc8f075412359822195c3cd9
round() function with precision argument rounding away from zero
User & Date: cdubois on 2026-01-12 04:27:04
Changes

  1. icomment:
    Thanks for the clarification, and +1 to dkf’s point: if Tcl ever grows first-class support for selectable rounding modes, a command (or small namespace) is probably the right shape.
    
    For the immediate need of rounding to a given number of decimal places, [format] is often sufficient for producing a rounded decimal representation, e.g.:
    
    set s [format "%.2f" $x]           ;# rounded string
    set y [expr {double($s)}]          ;# numeric value again (if needed)
    
    If a specific tie-breaking rule is required (e.g. “ties away from zero”), it may be better handled by a small helper at the script level, and a broader “multiple rounding modes” design can be discussed separately as its own RFE/TIP.
    
    Given the reporter’s follow-up, this ticket may be closable as “documentation/workaround provided”, leaving any more general rounding-mode support for a dedicated proposal.
    
  2. login: "cdubois"
  3. mimetype: "text/plain"