character class conversions [message #56328] |
Wed, 10 October 2007 14:29 |
jkj
Messages: 48 Registered: April 2007
|
Member |
|
|
Hi,
I found a resolution to my obstacle but the initial problem makes me
want to raise a question. I have two date/times expressed as
YYYYMMDDHHMMSS and wanted to find the mid-point date/time, initially
dividing their sum by "2.", giving me a double:
% set btime "19000101000000"
19000101000000
% set etime "21001231235959"
21001231235959
% set mid_time [expr {($btime + $etime) / 2.}]
2.0000666118e+13
...what I should have done was divide by "2"
% set mid_time [expr ($btime + $etime) / 2]
20000666117979
...but I never did come to grips with how to convert the double to an
integer and type-casting does not appear to be a friendly piece of
Tcl? I found one post related to type-casting and it was rather
involved with the poster providing five separate functions... isn't
there a simple way to take "2.0000666118e+13" and convert it to the
string "20000666117979"?
I notice that
"string is double $mid_time" returns true for the double and
"string is alnum $mid_time" returns true for the integer,
so it seems reasonable to think that Tcl provides some way of
converting from the character class double to alnum - am I overlooking
something simple?
Thanks,
-Kevin
|
|
|