[erlang-questions] How to write this code better?

Jilani Khaldi jilani@REDACTED
Mon Apr 14 11:11:36 CEST 2008


> 0.    Never write a literal value for pi.
>     3.14159 is *wrong*.  Use math:pi() instead.
Even math:pi() is *absolutely wrong* too and every numerical value you 
give to Pi is wrong. I have learnt this when I were, decades ago, a 
student in physics (yes, I have had a degres in physics before becoming 
architect!).
However, the correctness of a number depends on the context where you 
are using it.

>     So where does 89.99 come from?  Why is it 89.99 rather than 89.999?
>     Just how accurate *is* this formula anyway?
In many real world applications 89.9, 89.99 and 9.999 give the same 
pratical results!
See this image:
http://www.dotpas.org/software/shams1.jpg
It is the snapshop of a program I wrote many years ago using a very 
sophisticated sun position algorithm taking in consideration many 
factors. I normaly use it in my job to find the better orientation of a 
building and the positions and the dimensions of windows. The results 
are very accurated. However using the small and very simple program 
written in Erlang (I translated it on the fly from Javascript to Pascal 
and after to Erlang) gives results that are very similar to those given 
by the sophisticated one and could be applied for real world 
applications :-) For doing practical applications like daylight, 
sunlight, reinforced concrete calculations and many many others, I find 
writing small and simple applications (as set of functions) in Erlang 
using its interpreter as a calculator helps me very much during design 
and preliminary calculations (architecture and civil engineering speaking).
In many architecture applications an error even equal to 10% is to be 
considered technically correct :-).
*I am an architect which means a practical man and I find Erlang really 
helpful to be used this way*.
However, thank you for you advices!

-- 
***
Jilani KHALDI
http://www.dotpas.org



More information about the erlang-questions mailing list