🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.math.stat
Article #35

Re: Integer data in S

#35
From: Rick Becker
Date: Fri, 13 Jul 1984 11:47
31 lines
1763 bytes
> One needs to be careful when reading in data without decimal points to S.
> For example,
> 	1833008*2154246/2172348
> evaluates to
> 	771.15
> whereas
> 	1833008/2172348*2154246
> evaluates (as was intended) to
> 	1817734
> 
> Apparently multiplication of integers is done mod 2^32, whereas on division
> integers are changed to reals (of course, there is a separate integer
> divide if one wants to actually do that). I find this feature a bit
> disturbing, as I often work with data that are recorded in integer format,
> but really will be treated as real. 
> 

With real arithmetic, the operating system generates a floating
exception for overflow, and S generates an error message.
In integer arithmetic, no exception occurs, so it is hard for S to detect
the problem.

As you noted, division actually forces a real result, to
produce the expected 1.5 from 3/2.  The real arithmetic won't overflow
on numbers as small as what you have, but integer arithmetic will.
The advantage of integer arithmetic is that it keeps more digits of
precision (31 bits plus sign vs. 23 bits using real arithmetic), hence
integer operations are occasionally useful.
-- 

    Rick Becker  rabbit!rab
Technical Details
Message-ID: <2964@rabbit.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!alice!rabbit!rab
References: <47@entropy.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site rabbit.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!alice!rabbit!rab
From: rab@rabbit.UUCP (Rick Becker)
Newsgroups: net.math.stat
Subject: Re: Integer data in S
Message-ID: <2964@rabbit.UUCP>
Date: Fri, 13-Jul-84 07:47:18 EDT
Article-I.D.: rabbit.2964
Posted: Fri Jul 13 07:47:18 1984
Date-Received: Sat, 14-Jul-84 00:14:43 EDT
References: <47@entropy.UUCP>
Organization: AT&T Bell Laboratories, Murray Hill
Lines: 31