Skip to content
Tcl Source Code History Of Ticket 3564821fffffffffffffffffffffffffffffffff
Login

History Of Ticket 3564821fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 3564821fffffffffffffffffffffffffffffffff

  1. Ticket change [5a4e18d522] (rid 118121) by jmcuaz on 2012-09-04 21:22:46:

    1. assignee initialized to: "dgp"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      When dealing with floating point numbers, there is no easy way in tcl to do something like "round( 2.125 , 2 )" with an expected return of 2.13
      
      For the choice of upward/downward rounding (i.e. toward inf+ or inf-) and to disambiguate the semantic of rounding on negatives fp numbers, maybe two separate functions would be good : something like 
      roundup(x,y)  -> toward inf+
      rounddown(x,y) -> toward inf-
      
      Regards
      
      Jean-Marie Cuaz
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "jmcuaz"
    10. subsystem initialized to: "48. Number Handling"
    11. title initialized to:
      math rounding function with arbitrary decimal precision
      
    12. type initialized to: "RFE"
  2. Ticket change [2a16c826c2] (rid 118493) by sebres on 2012-09-05 16:16:48:

    1. icomment:
      Why can you not use "format" like this?
      % format %.2f 2.125
      2.13
      
      And if you really need a mathematical function, you can simple create it self, something like this:
      % proc ::tcl::mathfunc::roundup {n e} {double [format %.${e}f $n]}
      % puts [expr roundup( 2.555, 2 )]
      2.56
      
      
      
    2. login: "sebres"
    3. mimetype: "text/plain"
    4. username: "sebres"
  3. Ticket change [ec616519e0] (rid 103703) by jmcuaz on 2012-09-05 17:21:19:

    1. icomment:
      You are right.
      format f does an arithmetical rounding and not the simple truncation I understood when reading the doc : <quote>  For e, E, and f conversions it specifies the number of digits to appear to the right of the decimal point. <end of quote>.
      
      Sorry for the nuisance and thanks for the clarification
      
      Regards
      
      Jean-Marie
      
      
      
    2. login: "jmcuaz"
    3. mimetype: "text/plain"
    4. username: "jmcuaz"
  4. Ticket change [a853cfee37] (rid 98965) by sebres on 2012-09-05 17:44:50:

    1. closedate changed to: "2012-09-05T10:44:50"
    2. closer changed to: "sebres"
    3. resolution changed to: "Accepted"
    4. status changed to: "Closed"