This [expr] function returns the least floating point number with a zero fractional part that is no less than its argument (i.e., it rounds up). ---- The ceil command is a part of the [TclX] extension. TclX created command interfaces to a number of [Tcl] mathematical functions. So just read the [expr] documentation for ceil, and you will know what kind of arguments to pass to it. [RS]: Of course you can also write, if you wish ====== proc ceil x {expr {ceil($x)}} ====== so you don't have to require TclX... [LV] Certainly. However, the point was to document what the TclX ceil command does... [DKF]: Also available in Tcl 8.5 as '''[tcl::mathfunc]::ceil'''. ---- '''[MS] - 2014-05-13 07:04:24''' ([Miguel Sofer] is not the author of this comment, must be some other '''MS''') The ceil function fails if the difference to the number is smaller than 1e-15. expr ceil(34.000000000000001) = 34 by the interpreter. In most uses of ceil this will probably not be an issue but one has to keep it in mind so as to not lose information. I'm currently working on an elegant way to extend the ceil function and will post it once I've found something. ---- '''[MS] - 2014-05-13 12:31:02''' ([Miguel Sofer] is not the author of this comment, must be some other '''MS''') an elegant solution to the ceil problem (floor has the same bug and may be treated similar) is the following: ====== # the number is stored in arg, e.g. arg = 345.678, arg 345 proc ceil {req args} { if {$args != ""} { puts "To many arguments. Only one argument is allowed."} if {[string length [expr int($req)]] != [string length $req]}\ { set i 0 set empt "" while {[string index $req $i] != "." } {set empt "$empt[string index $req $i]";incr i} incr empt return $empt } else {return $req} } #empt = 346, arg = 345 #now there are two ceil procedures #new: ceil 34.0000000000000000000000001 -> 35 #old expr ceil(34.0000000000000000000000001) -> 34 ====== I didn't know that there is already someone with the initials MS sorry about that. I'll look into changing that. <> Function | Mathematics | Package