bug-bash
[Top][All Lists]
Advanced

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

division math problems in bash!


From: Charles Wilkins
Subject: division math problems in bash!
Date: Thu, 24 May 2001 21:14:52 GMT

I stumbled across this problem and am wondering if i am missing
something. It appears that bash on my system cannot divide properly.
The version of bash I am running is: 2.04.12(1) for linux-mandrake.

I included 2 example scripts and their output.
Both scripts yield different output and both outputs are wrong.

Any comments would be appreciated.

Best regards,
Charles Wilkins


#! /bin/sh
# math1

let bytes=62308352
let KB=($bytes/1024)
let KBR=($bytes%1024)
let MB=($KB/1024)
let MBR=($KB%1024)
let GB=($MB/1024)
let GBR=($KB%1048576)
echo "$bytes Bytes" 
echo "$KB.$KBR Kilobytes" 
echo "$MB.$MBR Megabytes"
echo "$GB.$GBR Gigabytes"


The output of "math1" is:
62308352 Bytes
60848.0 Kilobytes
59.432 Megabytes                this should be 59.421875
0.60848 Gigabytes               this should be 0.058029175

#! /bin/sh

let bytes=62308352
let KB=($bytes/1024)
let KBR=($bytes%1024)
let MB=($bytes/1048576)
let MBR=($bytes%1048576)
let GB=($bytes/1073741824)
let GBR=($bytes%1073741824)
echo "$bytes Bytes" 
echo "$KB.$KBR Kilobytes" 
echo "$MB.$MBR Megabytes"
echo "$GB.$GBR Gigabytes"

The output of "math2" is:
62308352 Bytes
60848.0 Kilobytes
59.442368 Megabytes             this should be 59.421875
0.62308352 Gigabytes            this should be 0.058029175





reply via email to

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