Re: Floating point arithmetic support in DCL
From: Alan Winston - SSRL Admin Cmptg Mgr (winston_at_SSRL.SLAC.STANFORD.EDU)
Date: 12/23/03
- Next message: jf.pieronne_at_laposte.net: "Re: Problems with MySQL (was Re: OpenVMS, CSWS (apache), PHP and... Rdb)"
- Previous message: Rob Young: "Re: Floating point arithmetic support in DCL"
- In reply to: Guy Peleg: "Re: Floating point arithmetic support in DCL"
- Next in thread: Guy Peleg: "Re: Floating point arithmetic support in DCL"
- Reply: Guy Peleg: "Re: Floating point arithmetic support in DCL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 ===============================================================================
- Next message: jf.pieronne_at_laposte.net: "Re: Problems with MySQL (was Re: OpenVMS, CSWS (apache), PHP and... Rdb)"
- Previous message: Rob Young: "Re: Floating point arithmetic support in DCL"
- In reply to: Guy Peleg: "Re: Floating point arithmetic support in DCL"
- Next in thread: Guy Peleg: "Re: Floating point arithmetic support in DCL"
- Reply: Guy Peleg: "Re: Floating point arithmetic support in DCL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|