🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #7562

Re: bash decimales

#7562
From: marmolejo
Date: Fri, 14 Feb 2003 17:54
59 lines
2575 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


	Autor:  Pacolinx <pacolinux@BORRAMEinicia.es>
	Asunto: bash decimales
	Fecha:  viernes, 14 de febrero de 2003
	Hora:   15:56 
	ID. del mensaje: <e6gvh-n35.ln1@paldaria.dsland.org>

>  Hola he hecho un cript pero no saca decimales
>  Como se puede consguir?

Con bash no puedes, hace las operaciones con enteros: (de man bash)

ARITHMETIC EVALUATION
       The  shell allows arithmetic expressions to be evaluated, under
certain circumstances (see the let builtin command and  Arithmetic
Expansion).  Evaluation  is done in fixed-width integers with no check
for overflow,

Yo usar�a "bc" as� pues los let ser�an:

>  let r=$1

r=$1

>  let pts=0,00

pts=0.00

>  let sol=0,00
>  let usd=0,00

>  
>  
>  if [ "$2" = "e" ]; then
>          let pts=r*166,386

        pts=`echo "scale=2;$r*166.386"|bc`

El resto an�logamente (si quieres exactitud con la conversi�n y el
redondeo "man bc")

>  echo euro=$euro pts=$pts sol=$sol usd=$usd

esta igual ;)
- -- 
Press any key to continue or other key to quit.
  Debian GNU/Linux Sid               <marmolejo at escomposlinux.org>
PGP Pub Key en pgp.escomposlinux.org ID:0x320A57C2 | Linux User #162799   

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+TS1eal36lDIKV8IRArTPAJ9ogxDyMLJ4z9kAP+QIySyVScqkQwCfW48V
MscIivWumB0R8CZLqHT6kjw=
=VUps
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <slrnb4qbao.2lr.marmolejo@porta.til>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!proxad.net!news-hub.cableinet.net!blueyonder!marmolejo.escomposlinux.org!porta.til!news
References: <e6gvh-n35.ln1@paldaria.dsland.org>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f86c8,362864e02625d68a
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2003-02-14 10:13:06 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!proxad.net!news-hub.cableinet.net!blueyonder!marmolejo.escomposlinux.org!porta.til!news
From: marmolejo <marmolejo@escomposlinux.org>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: bash decimales
Date: Fri, 14 Feb 2003 18:54:42 +0100
Organization: Ecolnet
Lines: 59
Message-ID: <slrnb4qbao.2lr.marmolejo@porta.til>
References: <e6gvh-n35.ln1@paldaria.dsland.org>
Reply-To: marmolejo@escomposlinux.org
NNTP-Posting-Host: portatil.debian.home
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
X-Trace: localhost.escomposlinux.org 1045246384 22460 192.168.1.3 (14 Feb 2003 18:13:04 GMT)
X-Complaints-To: newsmaster@marmolejo.escomposlinux.org
NNTP-Posting-Date: Fri, 14 Feb 2003 18:13:04 +0000 (UTC)
User-Agent: Gnus no y no