This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

trim number [solved]

Help for those learning Tcl or writing their own scripts.
Post Reply
t
tueb
Halfop
Posts: 76
Joined: Thu Oct 04, 2007 6:09 am
Location: #quiz.de @ irc.gamesurge.net
Contact:

trim number [solved]

Post by tueb »

Hi,

I calculate a duration by milliseconds by using:

"set dur [expr ([clock clicks -milliseconds] - $timeasked) * 0.001]"

that usually gives me a time like "64.409".

But on some networks (i.e. quakenet) i get times like "64.408999999999999".

How do i trim the number to three decimals?


thanks in advance,

tueb
Last edited by tueb on Wed Dec 22, 2010 7:00 am, edited 1 time in total.
#Quiz.de @ irc.GameSurge.net
JavaChat
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: trim number

Post by speechles »

Code: Select all

set dur [format %.3f [expr {([clock clicks -milliseconds] - $timeasked) * 0.001}]]
t
tueb
Halfop
Posts: 76
Joined: Thu Oct 04, 2007 6:09 am
Location: #quiz.de @ irc.gamesurge.net
Contact:

Post by tueb »

thanks!
#Quiz.de @ irc.GameSurge.net
JavaChat
Post Reply