calculating the area of a circle with bc

Colin Law clanlaw at googlemail.com
Sun Mar 28 19:26:58 UTC 2010


On 28 March 2010 20:24, Tony Arnold <tony.arnold at manchester.ac.uk> wrote:
> Jozsef,
>
> Since the area of a pizza is directly proportional to its diameter, you
> only really need to calculate the price/diameter to find out the best
> value for money!

It is proportional to the square of the diameter

Colin

>
> Regards,
> Tony.
>
> Jozsef Vadkan wrote:
>> input like:
>>
>> sh count.sh 0.45 2200
>> ...
>>
>> explanations:
>> 0.45 => diameter [in meter]
>>
>> 2200 => e.g. xy money
>>
>> $(echo "scale=100; 2^($1/2) * $(echo "scale=100; 4*a(1)" | bc -l)" | bc
>> -l) => area of the circle
>>
>> xy money => some nations currency
>>
>>
>> i'm dividing the area of the circle because i want to get the "xy
>> money/square meter"
>>
>>
>> #!/bin/bash
>>
>> echo "$2/$(echo "scale=100; 2^($1/2) * $(echo "scale=100; 4*a(1)" | bc
>> -l)" | bc -l)" | bc -l
>>
>>
>> is there a shorter/better way?
>>
>>
>> it would be a pizza price calculator. [:D]
>>
>> 45 cm pizza = 2200 xy money
>> 30 cm pizza = 1260 xy money
>> 22 cm pizza = 960 xy money
>>
>> i just want to count that, what will i have to choose to get the best
>> price for "xy money/square meter" pizza.
>>
>> don't laugh. [:D]
>>
>>
>
> --
> Tony Arnold,                        Tel: +44 (0) 161 275 6093
> Head of IT Security,                Fax: +44 (0) 870 136 1004
> University of Manchester,           Mob: +44 (0) 773 330 0039
> Manchester M13 9PL.                 Email: tony.arnold at manchester.ac.uk
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>




More information about the ubuntu-users mailing list