expr function available since Tcl 8.5: tcl::matchfunc::entier
Converts a number to some integral type (int, wide or bignum). This function was introduced in TIP#237 .
The name of this function is derived from French, via ALGOL [L1 ]. It also shows up in Tcl as a subcommand of string is
This is different from tcl::mathfunc::int in that it won't overflow:
% expr int(256**$::tcl_platform(wordSize)) 0 % expr entier(256**$::tcl_platform(wordSize)) 18446744073709551616
Note that entier will truncate the decimal part of a number, effectively 'rounding towards 0':
% expr entier(-1.6) -1 % expr entier(1.6) 1
Lars H: As a rounding function, this is unfortunately not particularly good. There a four common ways to round doubles to integers, three of which are useful:
and one which is not:
At least one specification of Algol (now linked above) was careful to not allow such behaviour for that entier.
2014-12-29: then again, entier isn't a rounding function. Like int or wide, it's a coercion function. If this coercion were combined with rounding, the implementation would in effect be making choices the programmer would like to have some control over.