Re: Floating point arithmetic support in DCL

mckinneyj_at_cpva.saic.com
Date: 12/31/03


Date: 31 Dec 03 11:24:26 PST

In article <jyUbuT+3w646@eisner.encompasserve.org>,
 briggs@encompasserve.org writes:
> In article <3FF24171.E9EDF72C@NeOaSrPtAhMlNiOnWk.net>, "David J. Dachtera" <djesys.nospam@NeOaSrPtAhMlNiOnWk.net> writes:
>> Charlie Hammond wrote:
>>>
>>> In article <3FF0F788.7862539F@NeOaSrPtAhMlNiOnWk.net>,
>>> "David J. Dachtera" <djesys.nospam@NeOaSrPtAhMlNiOnWk.net> writes:
>>> >Charlie Hammond wrote:
>>> ..
>>> >> Likewise if a5 = 5 and a4 = 4, then if a5 / a4 .eq. 1.25 and not just 1,
>>> >> the same problem exists.
>>> >
>>> >Rather depends on whether A5 and A4 were "declared" (implicitly or
>>> >explicitly) as integer or float.
>>> ..
>>>
>>> Exactly the problem.
>>>
>>> I "A = 5 / 4" results in an implicit declaration of A as float,
>>> then existing code breaks.
>>
>> 5 and 4 are both integer expressions. An integer result is reasonable to
>> expect. If A had been previously declared as float (by any means), the
>> potential for trouble may exist.
>
> But in DCL, symbols do not have declared data types. They take on
> the data type of the value that is assigned to them. If A had previously
> contained the value 3.1E+00 and been of type float then after the
> assignment it should contain the value 1 and be of type integer.
>
> i.e. the previous contents of A and data type of A are completely
> irrelevant.
>
> John Briggs

I agree with John.

Consider this - introduce a new assignment mechanism to declare
floating point data types - say, ".=" and ".==". This should protect
older code from failure. So, then we have

$ A = 5/4 ! A=1
$ A := 5/4 ! A="5/4"
$ A .= 5/4 ! A=1.25

The assignment operator always determines the data type in a way that
is independent of the datatypes and operations that appear on the the
right side of the assignment operator.

-- 
- Jim


Relevant Pages

  • Re: Numeric rounding not working?
    ... The data type decimal holds zero digits after the decimal point, ... declare @lat1 as float ...
    (microsoft.public.sqlserver.programming)
  • Re: Paper on PL/I
    ... all the number oare considerd fixed decimal compile time so all the math is done as fixed decimal until the assignment is reached at which point the fixed decimalnumber is converted to float bin. ... DECLARE X FLOAT; ...
    (comp.lang.pl1)
  • Re: newbie help.
    ... declare them on one line each for clarity. ... 'double' data type, rather than the 'float' type. ... | cin>>salary; ...
    (alt.comp.lang.learn.c-cpp)
  • Re: UDF and SQL2000 - Why doesnt this work?
    ... assignment to the @DailyVal variable is the problem. ... loop actually works when I return a datetime and only update the date. ... DECLARE @TempDate datetime ... DECLARE @TempVal float ...
    (microsoft.public.sqlserver.programming)
  • Re: Floating point arithmetic support in DCL
    ... >> then existing code breaks. ... If A had been previously declared as float, ... the data type of the value that is assigned to them. ... assignment it should contain the value 1 and be of type integer. ...
    (comp.os.vms)