On Tue, Jan 15, 2013 at 1:40 PM, Lionel Cons
<[email protected]> wrote:
> On 13 January 2013 22:49, Roland Mainz <[email protected]> wrote:
>> Does the POSIX _standard_ have anything against the idea that I can
>> pass an array _name_ to a function in an arithmetric expression ?
>> For example:
>> -- snip --
>> float -a ar=( 1.1 2.2 3.3 )
>>
>> float result
>> (( result=sumall(ar) ))
>> printf "result is %f\n" result
>> -- snip --
>> ... should print:
>> -- snip --
>> result is 6.6
>> -- snip --
>
> Passing arrays into arithmetic functions would IMO be useful for
> functions like fsum() (fsum() implements a more precise sum algorithm
> for floating point values, ref
> http://docs.python.org/3.1/library/math.html#math.fsum) which require
> to take a variable amount of values of the same type as input.

Erm... note that ksh93 always uses |long double| (if provided by the C
compiler and larger than the |double| datatype) ... which means on
Linux+Solaris/x86 you should get at least 80bit IEEE floating-point
numbers and 128bit IEEE floating-point on Solaris/SPARC (note that you
should use "float" in ksh93 syntax... which is an alias to the alway
"largest" floating-point datatype available, e.g. currently "typeset
-lE". Another issue might be the seralisation/seralisation of
floating-point values, e.g. floating-point-internal representation to
ASCII and backwards (which may introduce rounding errors because of
the base2<---->base10 conversion) ... if this is involved then you
should look at the C99 "hexfloat" notation which avoids the
base2<---->base10 conversion by providing a hexadecimal floating-point
representation.
ksh93 provides this feature via $ typeset -lX # and $ printf "%a"
varname # (do _not_ use ${varname} in this case...)).

If that's somehow not sufficient we should talk about implementing
something like the "Kahan summation algorithm" (see
http://en.wikipedia.org/wiki/Kahan_summation_algorithm ... this is
basically the same as used by Python).

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to