Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"But what we need to know is, do people want nasally-insertable computers?"


devel / comp.lang.fortran / Re: Spacing of real numbers around zero

SubjectAuthor
* Spacing of real numbers around zeroBeliavsky
`* Re: Spacing of real numbers around zerosteve kargl
 `- Re: Spacing of real numbers around zerogah4

1
Spacing of real numbers around zero

<c031c01a-5cea-4967-bb85-8b440fdcf33cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2148&group=comp.lang.fortran#2148

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:351:b0:2f1:fe90:2ffb with SMTP id r17-20020a05622a035100b002f1fe902ffbmr6849647qtw.396.1650383792962;
Tue, 19 Apr 2022 08:56:32 -0700 (PDT)
X-Received: by 2002:a25:7209:0:b0:645:3b43:94 with SMTP id n9-20020a257209000000b006453b430094mr3817515ybc.44.1650383792684;
Tue, 19 Apr 2022 08:56:32 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 19 Apr 2022 08:56:32 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=173.76.111.99; posting-account=Ac_J3QkAAABih73tf3Yz4sHazwGUM-hW
NNTP-Posting-Host: 173.76.111.99
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c031c01a-5cea-4967-bb85-8b440fdcf33cn@googlegroups.com>
Subject: Spacing of real numbers around zero
From: beliavsky@aol.com (Beliavsky)
Injection-Date: Tue, 19 Apr 2022 15:56:32 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 71
 by: Beliavsky - Tue, 19 Apr 2022 15:56 UTC

Spacing(0.0_wp) is supposed to give the number adjacent to zero, but it looks like that is actually given by epsilon(x) * tiny(x) , which is smaller. The output of the program

program main
use iso_fortran_env, only: int32, real32
implicit none
integer, parameter :: ikind = int32, wp = real32
integer (kind=ikind) :: i, nbits
integer, parameter :: ni = 4
real(kind=wp) :: x
nbits = bit_size(i)
print*,"bit_size(i) =",nbits
print*,"epsilon(x) =",epsilon(x)
print*,"tiny(x) =",tiny(x)
print*,"epsilon(x) * tiny(x) =",epsilon(x)*tiny(x)
print*,"spacing(0.0_wp) =",spacing(0.0_wp)
print "(/,a12,a16)","i","transfer(i,x)"
do i=0,ni
print*,i,transfer(i,x)
end do
end program main

with gfortran and ifort is

bit_size(i) = 32
epsilon(x) = 1.19209290E-07
tiny(x) = 1.17549435E-38
epsilon(x) * tiny(x) = 1.40129846E-45
spacing(0.0_wp) = 1.17549435E-38

i transfer(i,x)
0 0.00000000
1 1.40129846E-45
2 2.80259693E-45
3 4.20389539E-45
4 5.60519386E-45

and the output of the 64-bit program

program main
use iso_fortran_env, only: int64, real64
implicit none
integer, parameter :: ikind = int64, wp = real64
integer (kind=ikind) :: i, nbits
integer, parameter :: ni = 4
real(kind=wp) :: x
nbits = bit_size(i)
print*,"bit_size(i) =",nbits
print*,"epsilon(x) =",epsilon(x)
print*,"tiny(x) =",tiny(x)
print*,"epsilon(x) * tiny(x) =",epsilon(x)*tiny(x)
print*,"spacing(0.0_wp) =",spacing(0.0_wp)
print "(/,a21,a16)","i","transfer(i,x)"
do i=0,ni
print*,i,transfer(i,x)
end do
end program main

is

bit_size(i) = 64
epsilon(x) = 2.2204460492503131E-016
tiny(x) = 2.2250738585072014E-308
epsilon(x) * tiny(x) = 4.9406564584124654E-324
spacing(0.0_wp) = 2.2250738585072014E-308

i transfer(i,x)
0 0.0000000000000000
1 4.9406564584124654E-324
2 9.8813129168249309E-324
3 1.4821969375237396E-323
4 1.9762625833649862E-323

Re: Spacing of real numbers around zero

<t3n1eb$60k$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2152&group=comp.lang.fortran#2152

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: sgk@REMOVEtroutmask.apl.washington.edu (steve kargl)
Newsgroups: comp.lang.fortran
Subject: Re: Spacing of real numbers around zero
Date: Tue, 19 Apr 2022 19:10:03 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <t3n1eb$60k$1@dont-email.me>
References: <c031c01a-5cea-4967-bb85-8b440fdcf33cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Apr 2022 19:10:03 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4ad1872f8687f30e18b6515c9549d27e";
logging-data="6164"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192B/qD1/WwYd2TfgppQ21k"
User-Agent: XPN/1.2.6 (Street Spirit ; FreeBSD)
Cancel-Lock: sha1:8I8umYGC/f6kGaGPgdXwWsVcDlk=
 by: steve kargl - Tue, 19 Apr 2022 19:10 UTC

Beliavsky wrote:

> Spacing(0.0_wp) is supposed to give the number adjacent to zero,
> but it looks like that is actually given by epsilon(x) * tiny(x) , which
> is smaller. The output of the program

If your processor supports subnormal number, first nonzero positive
closest to 0 is 2**(-p-emin).

% cat z.f90
program foo
print *, 2.**(minexponent(1.) - digits(1.))
end

% gfcx -o z a.f90 && ./z
1.40129846E-45

The IEEE facilities of Fortran allow to query about subnormal numbers.

--
steve

Re: Spacing of real numbers around zero

<c023725b-7e95-41ea-8250-8b2e3bcde288n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2153&group=comp.lang.fortran#2153

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:2683:b0:69c:8c9c:5f80 with SMTP id c3-20020a05620a268300b0069c8c9c5f80mr10877974qkp.367.1650398371277;
Tue, 19 Apr 2022 12:59:31 -0700 (PDT)
X-Received: by 2002:a0d:e002:0:b0:2f1:bfa4:bdb8 with SMTP id
j2-20020a0de002000000b002f1bfa4bdb8mr7655531ywe.129.1650398371074; Tue, 19
Apr 2022 12:59:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 19 Apr 2022 12:59:30 -0700 (PDT)
In-Reply-To: <t3n1eb$60k$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=75.37.192.241; posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 75.37.192.241
References: <c031c01a-5cea-4967-bb85-8b440fdcf33cn@googlegroups.com> <t3n1eb$60k$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c023725b-7e95-41ea-8250-8b2e3bcde288n@googlegroups.com>
Subject: Re: Spacing of real numbers around zero
From: gah4@u.washington.edu (gah4)
Injection-Date: Tue, 19 Apr 2022 19:59:31 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 21
 by: gah4 - Tue, 19 Apr 2022 19:59 UTC

On Tuesday, April 19, 2022 at 12:10:06 PM UTC-7, steve kargl wrote:
> Beliavsky wrote:
>
> > Spacing(0.0_wp) is supposed to give the number adjacent to zero,
> > but it looks like that is actually given by epsilon(x) * tiny(x) , which
> > is smaller.

> If your processor supports subnormal number, first nonzero positive
> closest to 0 is 2**(-p-emin).

Which I never thought was a good idea. You get the equivalent
of about 0.04 extra exponent bits, for a lot of extra work
and/or hardware.

Note that the actual smallest number has zero significant bits.

It especially complicates parallel processors, like vector processors,
that try to do about the same amount of work for each one.

Even more, some require software help to get the right result.

If someone really sees the need, give it another whole exponent bit.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor