If you "intend a type" and that is an important part of your design, you
should use asserts to ensure that your result is of the type you intended.

That said, for most practical purposes a "type" is simply a range of values.

Mathematicians, for example, tend to make a careful distinction between
positive integers and non-negative integers. And a computer can only
approximate either "type" (though, granted, for many purposes the fact that
you cannot represent an infinity of extremely large integers is not an
issue for people).

Thanks,

-- 
Raul


On Mon, Aug 22, 2016 at 3:43 AM, Erling Hellenäs <[email protected]>
wrote:

> Hi all !
>
> As I see it when you write a complex system it is not easy to know what
> values different variables can take. A language with automatic type
> conversions makes this problem even more complex. Maybe when you designed
> and tested the system the variable had the type you intended. In production
> the user enters a value which causes the variable to be of a different type
> in which the loss of precision might occur, in which you can get memory
> full, in which the calculation is suddenly extremely slow, in which you get
> an exception or in which you get an unexpected NaN or infinite result.
> Since I did not investigate all these possibilities I just posed an open
> question about if this is relevant to the discussion.
> If the programmer controls the type he can be held accountable, when he
> does not he obviously still is held accountable, but the responsibility is
> harder to take and the resulting code might be more error prone. Errors in
> production might well be serious and can cause things like loss of life.
>
> I'll be back about the strange ones J invented.
>
> Cheers,
>
> Erling
>
>
> On 2016-08-20 19:38, Raul Miller wrote:
>
>> If loss of precision is a problem, you should be using extended precision
>> numbers (or rationals) for your values.
>>
>> And, of course, you should be careful to use operations whose results are
>> extended precision numbers (or rationals) for the values you are working
>> with.
>>
>> For example:
>>
>>     <.1r2+10^13x
>>
>> 10000000000000
>>
>>
>> Thanks,
>>
>>
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to