From owner-freebsd-questions@FreeBSD.ORG Thu Dec 14 00:58:35 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D2EBC16A4AB for ; Thu, 14 Dec 2006 00:58:35 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout2.cac.washington.edu (mxout2.cac.washington.edu [140.142.33.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id D6D3E43CD2 for ; Thu, 14 Dec 2006 00:56:43 +0000 (GMT) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.32.141]) by mxout2.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW06.09) with ESMTP id kBE0wFDR005268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 13 Dec 2006 16:58:15 -0800 X-Auth-Received: from [192.168.0.101] (dsl254-013-145.sea1.dsl.speakeasy.net [216.254.13.145]) (authenticated authid=youshi10) by smtp.washington.edu (8.13.7+UW06.06/8.13.7+UW06.09) with ESMTP id kBE0wEIQ022214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 13 Dec 2006 16:58:15 -0800 Message-ID: <4580A1AB.8070902@u.washington.edu> Date: Wed, 13 Dec 2006 16:58:19 -0800 From: Garrett Cooper User-Agent: Thunderbird 1.5.0.8 (X11/20061116) MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: In-Reply-To: X-Enigmail-Version: 0.94.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-PMX-Version: 5.2.2.285561, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2006.12.13.164433 X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='__CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __LINES_OF_YELLING 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' Subject: Re: mkxvcd not working due to floating point expression of movie length identification from mplayer X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Dec 2006 00:58:36 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Tsu-Fan Cheng wrote: > hi ... > i need to use mkxvcd script to create movies, but it gave me error > messages. After some debugging I found out it's because (I guess) that > mplayer use floating point expression instead of integer when identifying > the length of the movie, like 208.15 or something. Anyway, when mkxvcd > trying to decide how many hours this movie has by code: > HOURS=$[quant/3600], which quant means the length, > the script can't handle it and exit. > The script is written in Bash, and I am not so much of a expert, can > someone > suggest me the next step?? much appreciated!! > > > TFC Answer about whether or not floating point arithmetic is possible in bash (from ): Caution Bash does not understand floating point arithmetic. It treats numbers containing a decimal point as strings. Why not... A. Brute force the math a bit with Bash? 1. Divide the integer portion. 2. Subtract the quotient. 3. Take the decimal remainder and multiply it by 100 (or 1000 or whatever the max precision is for the number), and use that as your decimal value B. Program your solution using a different method / language? It's quite simple to accomplish this using either Perl or C. - -Garrett -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFgKGrEnKyINQw/HARAqyGAKCipeiM62ACpCEIjrYrZJqT0tdK1gCeJVRk FrMS1VUcScc000QIc1xPsaU= =ZCQS -----END PGP SIGNATURE-----