Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Dec 2006 16:58:19 -0800
From:      Garrett Cooper <youshi10@u.washington.edu>
To:        freebsd-questions@freebsd.org
Subject:   Re: mkxvcd not working due to floating point expression of movie length	identification from mplayer
Message-ID:  <4580A1AB.8070902@u.washington.edu>
In-Reply-To: <f84c38580612131632n486b0bfdw94c42489c5dfe1dc@mail.gmail.com>
References:  <f84c38580612131632n486b0bfdw94c42489c5dfe1dc@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
-----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 <http://tldp.org/LDP/abs/html/ops.html>):

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-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4580A1AB.8070902>