[cs615asa] bwinfo : rounding up

Jan Schaumann jschauma at cs.stevens.edu
Sun Apr 19 14:16:24 EDT 2009


Shashwath Veerappa Devaru <sveerapp at stevens.edu> wrote:
 
> I have written my code in shell script. I am not able to ceil or round up

Sure you could:

NUM=${1:?"Usage: $0 number"}
INT=${NUM%%.*}

if expr ${NUM} : "[0-9]*.[0-9]*" >/dev/null; then
        REM=${NUM##*.}

        if [ ${REM} -gt 0 ]; then
                INT=$(( ${INT} + 1 ))
        fi
fi

echo "Rounding ${NUM} yields ${INT}."


> the input and ouput rate so can i print decimals or should i leave it to
> floor automatically. If I print decimals will it cut my points?

Using decimals is perfectly fine, too.

-Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : https://lists.stevens.edu/cgi-bin/mailman/private/cs615asa/attachments/20090419/0db32dc4/attachment.pgp 


More information about the Cs615asa mailing list