Re: character class conversions [message #56314] |
Thu, 11 October 2007 07:34 |
Bob[3]
Messages: 60 Registered: December 2006
|
Member |
|
|
On Oct 10, 9:10 pm, jkj <ke...@vexona.com> wrote:
> On Oct 10, 4:29 pm, jkj <ke...@vexona.com> wrote:
>
>
>
>
>
>> 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
>
> Ooops! wrong board, eh??? :-)
> must have hit "Back" on the browser too many times...
> -Kevin- Hide quoted text -
>
> - Show quoted text -
I think your bigger problem is figuring out what "20000666117979"
means as a YYYYMMDDHHMMSS date/time, regardless of language used.
|
|
|
Re: character class conversions [message #56323 is a reply to message #56314] |
Wed, 10 October 2007 18:10  |
jkj
Messages: 48 Registered: April 2007
|
Member |
|
|
On Oct 10, 4:29 pm, jkj <ke...@vexona.com> wrote:
> 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
Ooops! wrong board, eh??? :-)
must have hit "Back" on the browser too many times...
-Kevin
|
|
|