Re: Floating point arithmetic support in DCL

From: Alan Winston - SSRL Admin Cmptg Mgr (winston_at_SSRL.SLAC.STANFORD.EDU)
Date: 12/23/03


Date: Tue, 23 Dec 2003 13:56:57 GMT

In article <ZBXFb.11208$%M4.9489@news.cpqcorp.net>, "Guy Peleg" <guy.peleg@hp.com_remove_this> writes:
>I would also like your feedback about the possibility of adding a lexical
>function to perform
>floating point math. As you might imagine adding floating point support is
>not easy, however,
>lexical functions are much easier to add. We can add a F$MATH lexical
>function
>to perform various types of arithmetic. For example:
>
>Write sys$output F$MATH("ADD","4.55","3.22")
>
>Other operands might be :sub,div,mul,sqrt,sin,cos,tan and what ever one
>would like.
>
>Pro : * Very easy to code (this is what I care about ;-)
> * I can commit this for V8.2
> * Can be provided for VAX & Alpha
> * Very easy to code
> * Less risk of breaking existing functionality
> * Easy to add operands in the future
>
>Con: result must be stored as a string
>
>What do you think?

Does this enable you to do arbitrary-precision math? If the result is coming
back as a string, I think you need to let the user specify the number of decimal
places wanted in the result, or maybe

Hmm, maybe F$MATH("RND",thing-to-round,number-of-places-to-round-to).

This might be a terrible idea, but could you have a default accumulator
location, so that calculations can be changed without always sticking the
return value into a symbol?

F$MATH("INIT") sets the accumulator to zero.
F$MATH("ADD","4.55") adds 4.55 to the accumulated value (now 4.55)
F$MATH("MUL","15.7") multiplies the accumulated value by 15.7
F$MATH("MUL","15.7","3") multiplies 15.7 by 3 and replaces the value in the
                         accumulator.
I'd also suggest - since it ought to be easy - making "-", "+", "/", and "*"
synonyms for "SUB", "ADD", "DIV", and "MUL".

(This makes it extremely easy to code a desk calculator in DCL. It also begins
to make it plausible to do RMS-database-based CGIs with computation, which is
kind of cool.)

All that said, I don't currently have a business case for this - but I like the
idea.

-- Alan

-- 
===============================================================================
 Alan Winston --- WINSTON@SSRL.SLAC.STANFORD.EDU
 Disclaimer: I speak only for myself, not SLAC or SSRL   Phone:  650/926-3056
 Paper mail to: SSRL -- SLAC BIN 99, 2575 Sand Hill Rd, Menlo Park CA   94025
===============================================================================


Relevant Pages

  • Re: converting float to double
    ... but this is also true of the integer math ... back conversion resulted in the original. ... of approximate inverse functions and what you have to do ... Doing it in floating point would be much more problematical. ...
    (comp.lang.c)
  • Re: Computer programmers habits in electronics
    ... on outside help temporarily to take care of the overflow. ... multiply it to a third, then we said "oh, by the way, our floating point ... real-world coordinates, and the number of pixels in real-world ... Once the math was done, and sorted out into something that worked well, ...
    (sci.electronics.design)
  • Tough problem...
    ... I am hoping somebody here has enough expirience ... in math and floating point round off errors, ...
    (borland.public.delphi.language.basm)
  • Re: math functions in module
    ... in the math library, libm, you must #includeand compile like ... If you meant "How can I use floating-point math in a kernel module?" ... Linus says "no floating point ...
    (comp.os.linux.misc)
  • Re: Amplitude response of a Biquad Filter
    ... I am experiencing even in the floating point implementation. ... Is 48 kHz tooo high a sampling freq. ... In a 16 bit DSP, the accumulator will be 32 bits + guard ...
    (comp.dsp)