| ||||||||
Rounding Down in Tcl Posted by eyarrow (eyarrow), 26 January 2004 Hi,Is there any package I can call.... so that I can round down in Tcl as opposed to rounding up? Many thanks Elliot Posted by admin (Graham Ellis), 26 January 2004 Hmm. I thought Tcl rounded down ...Code:
All of these are rounding down except the 11./3 which has rounded up in about the 12th significant figure. The -4 answer to the last test might be a suprise, but this is still rounding down. Can you post a more specific example of the sort of behaviour that you want to change, and I'll answer further Posted by eyarrow (eyarrow), 26 January 2004 Graham,Many thanks.. what I am refering to is as follows:- If we wish to round to 3 DP.... then normal rounding is as follows 1.64354 => 1.644 If we were to round down to 3Dp... then it would be as follows 1.64354 => 1.643 I believe, this is called ROUND_HALF_DOWN in Java. Many thanks Elliot Posted by admin (Graham Ellis), 26 January 2004 Easiest way is to use the floor function, but that rounds down to the nearest whole number. Here's a definition of a proc that does want you want (shifts your value, floors it, shifts it back)Code:
Demo of that in use: Code:
This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
| ||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |