Return-Path: Received: from mail-la0-f45.google.com ([209.85.215.45] verified) by media-motion.tv (CommuniGate Pro SMTP 4.2.10) with ESMTP-TLS id 5042844 for AE-List@media-motion.tv; Thu, 18 Apr 2013 17:05:42 +0200 Received: by mail-la0-f45.google.com with SMTP id gw10so2638921lab.4 for ; Thu, 18 Apr 2013 08:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=XdUOgFG5eboAQJMVISMAwsfcujdFg7V+DlqT1yQFB3Q=; b=r4uQB9dy5MwqZfumwjpSaUtYmCY8YTtbKYeawQJYYNvrGHd0UFyJk/NUv94H8K0aqy etDphHDTQqU34zPBHDrPMavz/bgwtbFT06b3rM6Okhg3jPIaGxNemFvOKiVkyPeB/nNI i/VicvcaH6FsgWd3+SuaU6OELJi5XkeeiX72Mm8VAAAmjeSmzNi2dgk4mBK2xI8+t9Ub ReMjRzzDnO+oZvEluQ4svDd8U3L1V3GSYxFipxFpm8sshu9CphbCQZkK5/VPBgWp6T9r yzRM4o7DmmFIyn2N0mh9TvxyYm6ZMDsiHSet5hZIcvTSZ39NrMU+pPEDjUQLAoZyGjbb T7hw== X-Received: by 10.112.155.67 with SMTP id vu3mr5959788lbb.109.1366298031637; Thu, 18 Apr 2013 08:13:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.87.239 with HTTP; Thu, 18 Apr 2013 08:13:31 -0700 (PDT) In-Reply-To: References: From: Byron Nash Date: Thu, 18 Apr 2013 11:13:31 -0400 Message-ID: Subject: Re: [AE] expressions: limiting decimals and adding 0 to single digit integers? To: After Effects Mail List Content-Type: multipart/alternative; boundary=089e0118306cd54c1c04daa40cb3 --089e0118306cd54c1c04daa40cb3 Content-Type: text/plain; charset=ISO-8859-1 Try doing a Round or floor mized with multiplying it by 100 to get a predictable number of zeroes. twoDigits = Math.round(num * 100) / 100; Basically multiply your number by 100 for two zeroes and round it. Then divide by 100 and you will have only two decimal places(rounded). On Wed, Apr 17, 2013 at 2:34 AM, James Culbertson wrote: > And is there a way to force the decimals to always be there even when they > are XX.00 or XX.X0? > > Thanks, > > James > > > On Apr 16, 2013, at 11:12 PM, Zack Lovatt wrote: > > From my understanding, this may be what you're looking for. Use this > instead of your existing code. Doesn't deal with the negative sign, though; > written hastily. In the morning I'll double check it and refine it to add > the negative! > > nums = thisComp.layer("shape").transform.rotation.value.toFixed(2) + ""; > > if ((nums < 10) && (nums > -10)) nums = "0" + nums; > > nums; > I am linking one layers rotation to a text layers source text. > > How do I modify the simple expression to limit the decimal to two places, > and at the same time make all integers two digits so 0 - 9 are 00, 01, > 02,...? > > Something like this but that adds two decimal places to the number: > > //--Expression begins > nums = thisComp.layer("shape").transform.rotation; > amtOfZeroes = 2; > //--Do not modify below this line > isNeg = false; > if(nums < 0) > { > nums = Math.abs( nums ); > isNeg = true; > } > sVal = Math.round( nums ) + ""; > while(sVal.length < amtOfZeroes) > { > sVal = "0" + sVal; > } > if(isNeg) > sVal = "-" + sVal; > > sVal > //--Expression ends > > > Thanks, James > > > +---End of message---+ > To unsubscribe send any message to > > > --089e0118306cd54c1c04daa40cb3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Try doing a Round or floor mized with multiplying it by 10= 0 to get a predictable number of zeroes.=A0

twoDig= its =3D Math.round(num * 100) / 100;

B= asically multiply your number by 100 for two zeroes and round it. Then divi= de by 100 and you will have only two decimal places(rounded).=A0


On Wed,= Apr 17, 2013 at 2:34 AM, James Culbertson <albion@speakeasy.net>= ; wrote:
And= is there a way to force the decimals to always be there even when they are= XX.00 or XX.X0?

Thanks,

James


On Apr 16, 2013, at 11:= 12 PM, Zack Lovatt wrote:

From my understanding, this may be what you're looking for. Use this in= stead of your existing code. Doesn't deal with the negative sign, thoug= h; written hastily. In the morning I'll double check it and refine it t= o add the negative!

nums =3D thisComp.layer("shape").transform.rotatio= n.value.toFixed(2) + "";

if ((nums < 10) &am= p;& (nums > -10)) nums =3D "0" + nums;

n= ums;

ae-list-off@media-motion.tv>


--089e0118306cd54c1c04daa40cb3--