shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A função scale no comando bc não está reduzindo para dois dígitos


From: itamarnet
Subject: Re: A função scale no comando bc não está reduzindo para dois dígitos
Date: 01 May 2015 20:14:20 -0700

Também costumo ter problemas desse gênero com bc no uso do scale, então costumo usar:

Com printf do bash:
LIMITE_COMPRA_01=$( LANG=C printf "%.2f\n" $( echo "$COTACAO_YUAN * 4.5" | bc ) )

Ou com awk:
LIMITE_COMPRA_01=$( echo "$COTACAO_YUAN 4.5" | awk '{printf "%.2f\n", $1 * $2}' )

É uma alternativa.

Serve?

[]'s
Itamar

reply via email to

[Prev in Thread] Current Thread [Next in Thread]