Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Silent gratitude isn't very much use to anyone." -- G. B. Stearn


devel / comp.lang.fortran / Applications of bit manipulation functions in Fortran

SubjectAuthor
* Applications of bit manipulation functions in FortranBeliavsky
+- Re: Applications of bit manipulation functions in Fortrangah4
+- Re: Applications of bit manipulation functions in FortranRobin Vowels
+* Re: Applications of bit manipulation functions in FortranRon Shepard
|+- Re: Applications of bit manipulation functions in FortranRobin Vowels
|`- Re: Applications of bit manipulation functions in Fortrangah4
+- Re: Applications of bit manipulation functions in FortranJames Van Buskirk
+* Re: Applications of bit manipulation functions in FortranGary Scott
|`- Re: Applications of bit manipulation functions in FortranBeliavsky
`* Re: Applications of bit manipulation functions in FortranDavid Duffy
 `* Re: Applications of bit manipulation functions in FortranWalter Spector
  `* Re: Applications of bit manipulation functions in FortranRobin Vowels
   `* Re: Applications of bit manipulation functions in FortranWalter Spector
    `- Re: Applications of bit manipulation functions in FortranRobin Vowels

1
Applications of bit manipulation functions in Fortran

<16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:191:b0:2f1:ffe6:283c with SMTP id s17-20020a05622a019100b002f1ffe6283cmr4673255qtw.557.1650335740535;
Mon, 18 Apr 2022 19:35:40 -0700 (PDT)
X-Received: by 2002:a81:5309:0:b0:2e6:dcfc:8665 with SMTP id
h9-20020a815309000000b002e6dcfc8665mr13018072ywb.501.1650335740369; Mon, 18
Apr 2022 19:35:40 -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: Mon, 18 Apr 2022 19:35:40 -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: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
Subject: Applications of bit manipulation functions in Fortran
From: beliavsky@aol.com (Beliavsky)
Injection-Date: Tue, 19 Apr 2022 02:35:40 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 3
 by: Beliavsky - Tue, 19 Apr 2022 02:35 UTC

The BTEST intrinsic function can be used to extract bits from the representation of an integer. It's useful to be able to store 32
booleans in an int32. What are some applications of the Fortran
bit manipulation intrinsic functions, discussed at http://www2.phys.canterbury.ac.nz/dept/docs/manuals/Fortran-90/HTMLNotesnode158.html for example, that could be tweeted about?
I have read the Wikipedia article https://en.wikipedia.org/wiki/Bit_manipulation .

Re: Applications of bit manipulation functions in Fortran

<57189a46-896a-45f6-b1b5-7f001568c80bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:1cc4:b0:435:b8a0:1fe9 with SMTP id g4-20020a0562141cc400b00435b8a01fe9mr10471310qvd.54.1650347979019;
Mon, 18 Apr 2022 22:59:39 -0700 (PDT)
X-Received: by 2002:a25:6d85:0:b0:645:192e:31ed with SMTP id
i127-20020a256d85000000b00645192e31edmr5228796ybc.16.1650347978762; Mon, 18
Apr 2022 22:59:38 -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: Mon, 18 Apr 2022 22:59:38 -0700 (PDT)
In-Reply-To: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=75.37.192.241; posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 75.37.192.241
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <57189a46-896a-45f6-b1b5-7f001568c80bn@googlegroups.com>
Subject: Re: Applications of bit manipulation functions in Fortran
From: gah4@u.washington.edu (gah4)
Injection-Date: Tue, 19 Apr 2022 05:59:39 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 16
 by: gah4 - Tue, 19 Apr 2022 05:59 UTC

On Monday, April 18, 2022 at 7:35:42 PM UTC-7, Beliavsky wrote:
> The BTEST intrinsic function can be used to extract bits from the
> representation of an integer. It's useful to be able to store 32
> booleans in an int32. What are some applications of the Fortran
> bit manipulation intrinsic functions, discussed at
> http://www2.phys.canterbury.ac.nz/dept/docs/manuals/Fortran-90/HTMLNotesnode158.html
> for example, that could be tweeted about?
> I have read the Wikipedia article https://en.wikipedia.org/wiki/Bit_manipulation .

A fair number of problems consider bits as bits, and not as numbers.

One common one is bitmap graphics, especially the case where pixels
are either on or off, white or black. You can address a pixel by the location
of a byte or larger word, and bit within the word.

Another that is commonly done with bits, though not always single
bits, is compression algorithms.

Re: Applications of bit manipulation functions in Fortran

<fab9ca88-3d10-4c4b-9be6-6a4f18e7bad4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:7f54:0:b0:2f1:f48c:c73a with SMTP id g20-20020ac87f54000000b002f1f48cc73amr9980714qtk.265.1650382495189;
Tue, 19 Apr 2022 08:34:55 -0700 (PDT)
X-Received: by 2002:a0d:eb8f:0:b0:2eb:f1e4:2653 with SMTP id
u137-20020a0deb8f000000b002ebf1e42653mr15560504ywe.401.1650382494986; Tue, 19
Apr 2022 08:34:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!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:34:54 -0700 (PDT)
In-Reply-To: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=202.67.103.232; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le
NNTP-Posting-Host: 202.67.103.232
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fab9ca88-3d10-4c4b-9be6-6a4f18e7bad4n@googlegroups.com>
Subject: Re: Applications of bit manipulation functions in Fortran
From: robin.vowels@gmail.com (Robin Vowels)
Injection-Date: Tue, 19 Apr 2022 15:34:55 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Robin Vowels - Tue, 19 Apr 2022 15:34 UTC

On Tuesday, April 19, 2022 at 12:35:42 PM UTC+10, Beliavsky wrote:
> The BTEST intrinsic function can be used to extract bits from the representation of an integer. It's useful to be able to store 32
> booleans in an int32. What are some applications of the Fortran
> bit manipulation intrinsic functions, discussed at http://www2.phys.canterbury.ac.nz/dept/docs/manuals/Fortran-90/HTMLNotesnode158.html for example, that could be tweeted about?
> I have read the Wikipedia article https://en.wikipedia.org/wiki/Bit_manipulation .
..
The algorithm for generating Fibonacci numbers can conveniently dine with bits.

Re: Applications of bit manipulation functions in Fortran

<lkB7K.611014$LN2.116577@fx13.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0)
Gecko/20100101 Thunderbird/91.8.0
Subject: Re: Applications of bit manipulation functions in Fortran
Content-Language: en-US
Newsgroups: comp.lang.fortran
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
From: nospam@nowhere.org (Ron Shepard)
In-Reply-To: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 49
Message-ID: <lkB7K.611014$LN2.116577@fx13.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 19 Apr 2022 11:21:37 -0500
X-Received-Bytes: 4228
 by: Ron Shepard - Tue, 19 Apr 2022 16:21 UTC

On 4/18/22 9:35 PM, Beliavsky wrote:
> The BTEST intrinsic function can be used to extract bits from the representation of an integer. It's useful to be able to store 32
> booleans in an int32. What are some applications of the Fortran
> bit manipulation intrinsic functions, discussed at http://www2.phys.canterbury.ac.nz/dept/docs/manuals/Fortran-90/HTMLNotesnode158.html for example, that could be tweeted about?
> I have read the Wikipedia article https://en.wikipedia.org/wiki/Bit_manipulation .

Probably the most common application in my field is to pack small values
into larger integer words. If you have some integers that are known to
be between 0 and 31, or example, then they only need 5 bits to represent
their value. So you can pack several within an integer, or you can
combine several such integers of different ranges all together into a
single word. In the old days when memory was scarce, this would reduce
the overall memory footprint, and also it reduces the i/o costs and
external storage requirements. I/O is many hundreds of times more
expensive than the bit operations required to pack and unpack the data,
so this was and still is a good tradeoff. This is usually done with
shifting (ISHFT) and masking operations (IOR).

Another common use is the representation of wave functions in
second-quantized occupation number form. If a bit is 0 then that means
that the spin-orbital is empty in the Slater determinant, if it is 1
then that spin-orbital is occupied. In this application, the programmer
needs to test individual bits (BTEST), set individual bits (IBSET),
clear individual bits (IBCLR), look at mismatches between two
determinants (IEOR), and count the number of bits that are set between
two locations (POPCNT). For some reason, that last operation is not
included in the list at the above link. This application dates back to
the 1960s and 1970s, well before any of the fortran bit operators were
standardized, so originally they were all done with compiler extensions
or with assembly code. As long as the number of spin-orbitals is less
than the integer word length, this is all pretty straightforward to do
with the fortran operators, but when multiple words are required, then
it all gets more complicated. That is where a fortran bitstring data
type would help the programmer. Then all of this could be done with just
fortran intrinsic data types and fortran intrinsic operators. Otherwise,
the programmer needs to do all those operations the hard way.

I have stated in the past that it was almost impossible to write useful
f66 and f77 programs without relying on compiler extensions. This is one
of the applications that displayed the inadequacies of the language in
that era. No standard bit operators, no bitstring data type, there just
wasn't any real support at all in the standard language to do any of
this. Now, the language has improved, but ironically this is no longer
the popular way to do these operations. Now they are usually done with
graphical-network based algorithms which were originally developed as a
workaround for the lack of language support, and eventually became the
preferred approach.

$.02 -Ron Shepard

Re: Applications of bit manipulation functions in Fortran

<t3mok4$vpb$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: not_valid@comcast.net (James Van Buskirk)
Newsgroups: comp.lang.fortran
Subject: Re: Applications of bit manipulation functions in Fortran
Date: Tue, 19 Apr 2022 10:39:24 -0600
Organization: A noiseless patient Spider
Lines: 1
Message-ID: <t3mok4$vpb$1@dont-email.me>
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="UTF-8";
reply-type=original
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Apr 2022 16:39:32 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a742bf3cc47d2c1aaa6af79ef4c31e6e";
logging-data="32555"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19drwDWcp/M212xLWIQFF+waatGH2HPnnI="
Cancel-Lock: sha1:oUAPspLC4Ff/VO/Q0BEcR27A09M=
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
In-Reply-To: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
Importance: Normal
X-Priority: 3
X-MSMail-Priority: Normal
 by: James Van Buskirk - Tue, 19 Apr 2022 16:39 UTC

"Beliavsky" wrote in message
news:16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com...

> The BTEST intrinsic function can be used to extract bits from the
> representation of an integer. It's useful to be able to store 32
> booleans in an int32. What are some applications of the Fortran
> bit manipulation intrinsic functions, discussed at
> http://www2.phys.canterbury.ac.nz/dept/docs/manuals/Fortran-90/HTMLNotesnode158.html
> for example, that could be tweeted about?
> I have read the Wikipedia article
> https://en.wikipedia.org/wiki/Bit_manipulation .

Well, there is the sieve of Eratosthenes. A big sieve table takes less
memory when implemented as a bit array. At some point the algorithm
will experience cache thrashing and that point happens later with
bit arrays. Sieving with small primes can also happen several steps in one
operation because, for example AVX2 can .AND. or .OR. with a 256-bit
wide register.

There is also bit reversal algorithm that stores a bit reversal table of
half the size of the indices to be reversed and then composes pairs
of bit reversed indices from them. It works well for bit reversal in
place.

Re: Applications of bit manipulation functions in Fortran

<d01d5615-112e-4d95-b27d-a795eff07bf6n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a0c:f885:0:b0:444:416a:3f7a with SMTP id u5-20020a0cf885000000b00444416a3f7amr12668177qvn.127.1650386490585;
Tue, 19 Apr 2022 09:41:30 -0700 (PDT)
X-Received: by 2002:a81:2485:0:b0:2ec:354d:d45a with SMTP id
k127-20020a812485000000b002ec354dd45amr16249562ywk.213.1650386490333; Tue, 19
Apr 2022 09:41:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.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 09:41:30 -0700 (PDT)
In-Reply-To: <lkB7K.611014$LN2.116577@fx13.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=202.67.103.232; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le
NNTP-Posting-Host: 202.67.103.232
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com> <lkB7K.611014$LN2.116577@fx13.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d01d5615-112e-4d95-b27d-a795eff07bf6n@googlegroups.com>
Subject: Re: Applications of bit manipulation functions in Fortran
From: robin.vowels@gmail.com (Robin Vowels)
Injection-Date: Tue, 19 Apr 2022 16:41:30 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 66
 by: Robin Vowels - Tue, 19 Apr 2022 16:41 UTC

On Wednesday, April 20, 2022 at 2:21:41 AM UTC+10, Ron Shepard wrote:
> On 4/18/22 9:35 PM, Beliavsky wrote:
> > The BTEST intrinsic function can be used to extract bits from the representation of an integer. It's useful to be able to store 32
> > booleans in an int32. What are some applications of the Fortran
> > bit manipulation intrinsic functions, discussed at http://www2.phys.canterbury.ac.nz/dept/docs/manuals/Fortran-90/HTMLNotesnode158.html for example, that could be tweeted about?
> > I have read the Wikipedia article https://en.wikipedia.org/wiki/Bit_manipulation .
..
> Probably the most common application in my field is to pack small values
> into larger integer words. If you have some integers that are known to
> be between 0 and 31, or example, then they only need 5 bits to represent
> their value. So you can pack several within an integer,
..
Or you could check whether your compiler offers 1-byte integers, which can hold
signed values to 127.
..
>or you can
> combine several such integers of different ranges all together into a
> single word. In the old days when memory was scarce, this would reduce
> the overall memory footprint,
..
In the old days, 16-bit integers were available,
and decimal integers in the range -9 through 9 were available
for arrays containing small values. They weren't available in FORTRAN,
but were available in PL/I without any special programming (and still are).
Signed integers in the range -128 through 127 are currently available
when one byte is used. Unsigned integers in the range 0 thru 255 are
also available. These are useful for handling picture files.
..
> and also it reduces the i/o costs and
> external storage requirements. I/O is many hundreds of times more
> expensive than the bit operations required to pack and unpack the data,
> so this was and still is a good tradeoff. This is usually done with
> shifting (ISHFT) and masking operations (IOR).
>
> Another common use is the representation of wave functions in
> second-quantized occupation number form. If a bit is 0 then that means
> that the spin-orbital is empty in the Slater determinant, if it is 1
> then that spin-orbital is occupied. In this application, the programmer
> needs to test individual bits (BTEST), set individual bits (IBSET),
> clear individual bits (IBCLR), look at mismatches between two
> determinants (IEOR), and count the number of bits that are set between
> two locations (POPCNT). For some reason, that last operation is not
> included in the list at the above link. This application dates back to
> the 1960s and 1970s, well before any of the fortran bit operators were
> standardized,
..
But bit operations were available in PL/I from 1966.
..
> so originally they were all done with compiler extensions
> or with assembly code. As long as the number of spin-orbitals is less
> than the integer word length, this is all pretty straightforward to do
> with the fortran operators, but when multiple words are required, then
> it all gets more complicated. That is where a fortran bitstring data
> type would help the programmer. Then all of this could be done with just
> fortran intrinsic data types and fortran intrinsic operators. Otherwise,
> the programmer needs to do all those operations the hard way.
>
> I have stated in the past that it was almost impossible to write useful
> f66 and f77 programs without relying on compiler extensions. This is one
> of the applications that displayed the inadequacies of the language in
> that era. No standard bit operators, no bitstring data type, there just
> wasn't any real support at all in the standard language to do any of
> this. Now, the language has improved, but ironically this is no longer
> the popular way to do these operations. Now they are usually done with
> graphical-network based algorithms which were originally developed as a
> workaround for the lack of language support, and eventually became the
> preferred approach.

Re: Applications of bit manipulation functions in Fortran

<9f2c6ff8-2ce8-441c-badf-90bc2a7db048n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ad4:5be6:0:b0:446:53cf:7bf7 with SMTP id k6-20020ad45be6000000b0044653cf7bf7mr9541356qvc.94.1650398865673;
Tue, 19 Apr 2022 13:07:45 -0700 (PDT)
X-Received: by 2002:a25:6d85:0:b0:645:192e:31ed with SMTP id
i127-20020a256d85000000b00645192e31edmr8563740ybc.16.1650398865447; Tue, 19
Apr 2022 13:07:45 -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 13:07:45 -0700 (PDT)
In-Reply-To: <lkB7K.611014$LN2.116577@fx13.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=75.37.192.241; posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 75.37.192.241
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com> <lkB7K.611014$LN2.116577@fx13.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9f2c6ff8-2ce8-441c-badf-90bc2a7db048n@googlegroups.com>
Subject: Re: Applications of bit manipulation functions in Fortran
From: gah4@u.washington.edu (gah4)
Injection-Date: Tue, 19 Apr 2022 20:07:45 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 21
 by: gah4 - Tue, 19 Apr 2022 20:07 UTC

On Tuesday, April 19, 2022 at 9:21:41 AM UTC-7, Ron Shepard wrote:

(snip)

> Probably the most common application in my field is to pack small values
> into larger integer words. If you have some integers that are known to
> be between 0 and 31, or example, then they only need 5 bits to represent
> their value. So you can pack several within an integer, or you can
> combine several such integers of different ranges all together into a
> single word. In the old days when memory was scarce, this would reduce
> the overall memory footprint, and also it reduces the i/o costs and
> external storage requirements. I/O is many hundreds of times more
> expensive than the bit operations required to pack and unpack the data,
> so this was and still is a good tradeoff. This is usually done with
> shifting (ISHFT) and masking operations (IOR).

Without bit shifting and IOR, though usually without using the
sign bit, you can easily do it with divide and MOD.

Even more, with divide and MOD, you are not limited to only
powers of two, thought it might be a little slower.

Re: Applications of bit manipulation functions in Fortran

<t3n8eo$rpj$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: garylscott@sbcglobal.net (Gary Scott)
Newsgroups: comp.lang.fortran
Subject: Re: Applications of bit manipulation functions in Fortran
Date: Tue, 19 Apr 2022 16:09:44 -0500
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <t3n8eo$rpj$1@dont-email.me>
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Apr 2022 21:09:45 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f16a71e4853140277f75e4df30eee4aa";
logging-data="28467"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xFPxC1Qi6lGATGBF6YbAgieT22uNyKPU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Cancel-Lock: sha1:lVRJim0O7iv0QvaBxiJscaG/Log=
In-Reply-To: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
Content-Language: en-US
 by: Gary Scott - Tue, 19 Apr 2022 21:09 UTC

On 4/18/2022 9:35 PM, Beliavsky wrote:
> The BTEST intrinsic function can be used to extract bits from the representation of an integer. It's useful to be able to store 32
> booleans in an int32. What are some applications of the Fortran
> bit manipulation intrinsic functions, discussed at http://www2.phys.canterbury.ac.nz/dept/docs/manuals/Fortran-90/HTMLNotesnode158.html for example, that could be tweeted about?
> I have read the Wikipedia article https://en.wikipedia.org/wiki/Bit_manipulation .
In aerospace/avionics, we had to interface dozens to 100s of small
embedded processors communicating via serial bus. Because bandwidth was
limited, we defined our data as efficiently as possible to fit within
the 16-bit words of the serial bus (and many of the target processors).
We also hosted simulations/emulations of some of those small embedded
processors on minicomputers (Datacraft/Gould/Encore/Harris/Concurrent
VOS primarily) depending on the particular test environment needs (all
other or only some embedded processors may be modeled). Also, data
recording and retrieval processes hosted on the minis would conveniently
format the serial bus (or internal) data into useful units if requested.
Needless to say, there is a huge amount of bit manipulation to
translate betweeen the serial bus data formats and the needs internally
of the models which were 24-bit word-based. Harris Fortran had
extensions which allowed you to write these in the form:

intval1 = intval2 .shift. -8 .and. '177 .or. '1 .rotat. 2

The "Purdue" bit extensions were implemented, but rarely used in favor
of the above syntax.

Re: Applications of bit manipulation functions in Fortran

<b44f5ec9-7e16-4236-8965-c7ded39884c3n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:191:b0:2f1:ffe6:283c with SMTP id s17-20020a05622a019100b002f1ffe6283cmr7567637qtw.557.1650407264333;
Tue, 19 Apr 2022 15:27:44 -0700 (PDT)
X-Received: by 2002:a05:6902:c8:b0:633:ee0c:bca2 with SMTP id
i8-20020a05690200c800b00633ee0cbca2mr18061486ybs.82.1650407264062; Tue, 19
Apr 2022 15:27:44 -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 15:27:43 -0700 (PDT)
In-Reply-To: <t3n8eo$rpj$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=173.76.111.99; posting-account=Ac_J3QkAAABih73tf3Yz4sHazwGUM-hW
NNTP-Posting-Host: 173.76.111.99
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com> <t3n8eo$rpj$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b44f5ec9-7e16-4236-8965-c7ded39884c3n@googlegroups.com>
Subject: Re: Applications of bit manipulation functions in Fortran
From: beliavsky@aol.com (Beliavsky)
Injection-Date: Tue, 19 Apr 2022 22:27:44 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 26
 by: Beliavsky - Tue, 19 Apr 2022 22:27 UTC

On Tuesday, April 19, 2022 at 5:09:48 PM UTC-4, Gary Scott wrote:
> On 4/18/2022 9:35 PM, Beliavsky wrote:
> > The BTEST intrinsic function can be used to extract bits from the representation of an integer. It's useful to be able to store 32
> > booleans in an int32. What are some applications of the Fortran
> > bit manipulation intrinsic functions, discussed at http://www2.phys.canterbury.ac.nz/dept/docs/manuals/Fortran-90/HTMLNotesnode158.html for example, that could be tweeted about?
> > I have read the Wikipedia article https://en.wikipedia.org/wiki/Bit_manipulation .
> In aerospace/avionics, we had to interface dozens to 100s of small
> embedded processors communicating via serial bus. Because bandwidth was
> limited, we defined our data as efficiently as possible to fit within
> the 16-bit words of the serial bus (and many of the target processors).
> We also hosted simulations/emulations of some of those small embedded
> processors on minicomputers (Datacraft/Gould/Encore/Harris/Concurrent
> VOS primarily) depending on the particular test environment needs (all
> other or only some embedded processors may be modeled). Also, data
> recording and retrieval processes hosted on the minis would conveniently
> format the serial bus (or internal) data into useful units if requested.
> Needless to say, there is a huge amount of bit manipulation to
> translate betweeen the serial bus data formats and the needs internally
> of the models which were 24-bit word-based. Harris Fortran had
> extensions which allowed you to write these in the form:
>
> intval1 = intval2 .shift. -8 .and. '177 .or. '1 .rotat. 2
>
> The "Purdue" bit extensions were implemented, but rarely used in favor
> of the above syntax.

Thanks to you and others for the informative replies.

Re: Applications of bit manipulation functions in Fortran

<t3o428$1vq2$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!news.swapon.de!aioe.org!xPvm3XcqrOPFJ3ePU5HxpQ.user.46.165.242.75.POSTED!not-for-mail
From: davidD@qimr.edu.au (David Duffy)
Newsgroups: comp.lang.fortran
Subject: Re: Applications of bit manipulation functions in Fortran
Date: Wed, 20 Apr 2022 05:00:58 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t3o428$1vq2$1@gioia.aioe.org>
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
Injection-Info: gioia.aioe.org; logging-data="65346"; posting-host="xPvm3XcqrOPFJ3ePU5HxpQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.4.4-20191224 ("Millburn") (Linux/5.4.0-107-generic (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: David Duffy - Wed, 20 Apr 2022 05:00 UTC

Beliavsky <beliavsky@aol.com> wrote:
> The BTEST intrinsic function can be used to extract bits from the representation of an integer. It's useful to be able to store 32
> booleans in an int32. What are some applications of the Fortran
> bit manipulation intrinsic functions, discussed at http://www2.phys.canterbury.ac.nz/dept/docs/manuals/Fortran-90/HTMLNotesnode158.html for example, that could be tweeted about?
> I have read the Wikipedia article https://en.wikipedia.org/wiki/Bit_manipulation .

Reading bitcodes from C

integer(c_int) :: ir
character (len=2), dimension(0:3), parameter :: sizes = &
(/'16', '32', '64', 'Ot'/)
ir=zlibcompileflags()
write(outstr, '(2a)', advance='no') ' uInt:', sizes(ibits(ir,0,2))
write(outstr, '(2a)') ' z_off_t:', sizes(ibits(ir,6,2))

Hash codes

! hash code to memoize (unique file name for) a matrix - after the Java equivalent
! function hashmat(n, c)
character (len=16) :: hashmat
integer, intent(in) :: n
double precision, dimension(:), intent(in) :: c
integer (kind=8) :: bits, h

h=123456789
do i=1, n
bits = transfer(c(i), bits)
h = h * 31 + ieor(bits, ishft(bits, -32))
end do
write(hashmat,'(z16)') h
end function hashmat
!

Cheers, David Duffy.

Re: Applications of bit manipulation functions in Fortran

<e0a8db14-9ac9-4208-be4c-a71108f3b565n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:1d08:b0:45a:a692:3bb2 with SMTP id e8-20020a0562141d0800b0045aa6923bb2mr12014491qvd.24.1652070757258;
Sun, 08 May 2022 21:32:37 -0700 (PDT)
X-Received: by 2002:a0d:d5d2:0:b0:2f7:c85d:2c0d with SMTP id
x201-20020a0dd5d2000000b002f7c85d2c0dmr12158356ywd.5.1652070757031; Sun, 08
May 2022 21:32:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Sun, 8 May 2022 21:32:36 -0700 (PDT)
In-Reply-To: <t3o428$1vq2$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:ccd0:bda0:db20:2a44:d583:fbb4;
posting-account=rI197goAAAC_3Br9qa3zpMvdPg0TDLVr
NNTP-Posting-Host: 2600:1700:ccd0:bda0:db20:2a44:d583:fbb4
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com> <t3o428$1vq2$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e0a8db14-9ac9-4208-be4c-a71108f3b565n@googlegroups.com>
Subject: Re: Applications of bit manipulation functions in Fortran
From: w6ws@earthlink.net (Walter Spector)
Injection-Date: Mon, 09 May 2022 04:32:37 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Walter Spector - Mon, 9 May 2022 04:32 UTC

Prior to Fortran 77, there was no character data type. Hollerith constants were used to set character strings into numeric variables.
String size fixed to the number of characters a 'numeric storage unit' (NSU) could hold. Various machines allowed packing anywhere from 2 to 10 characters per integer, and 4 to 10 characters per real. (The compilers with 2 characters per integer/4 characters per real didn't conform to the Standard - since a NSU is supposed to be the same number of bits regardless of data type.) Unless one restricted oneself to a single character per NSU, which could be terribly wasteful of memory in those days, it was hard to write portable character string handling code. Bit manipulation for accessing individual characters in packed words was extremely common, non-portable, and error prone.

Fortran 77 changed all that with its character data type. Though it took years for some programmers to update their codes to use it. There are early adopters who take advantage of new features to clean up their code, make things more reliable and easier to maintain. Then there are those who wait until the very last moment before their favorite computer system or compiler disappears and they are forced to change. Or they retire first, and their codes die after they leave because no one wants to touch the. (Then complain about it for the next 20 years on these Internet forums...)

I've rarely needed to use the bit intrinsics since Fortran 77 (+ Mil Spec extensions) came out. But at least when I do, the spelling and functionality of the intrinsics are standardized now.

Re: Applications of bit manipulation functions in Fortran

<d86270fd-0171-4807-944e-a0b6b4b93453n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:5905:0:b0:2f3:9fdd:22f1 with SMTP id 5-20020ac85905000000b002f39fdd22f1mr13400398qty.191.1652080231453;
Mon, 09 May 2022 00:10:31 -0700 (PDT)
X-Received: by 2002:a81:1196:0:b0:2f8:ccab:8807 with SMTP id
144-20020a811196000000b002f8ccab8807mr12766164ywr.58.1652080231281; Mon, 09
May 2022 00:10:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 9 May 2022 00:10:31 -0700 (PDT)
In-Reply-To: <e0a8db14-9ac9-4208-be4c-a71108f3b565n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=202.67.103.232; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le
NNTP-Posting-Host: 202.67.103.232
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
<t3o428$1vq2$1@gioia.aioe.org> <e0a8db14-9ac9-4208-be4c-a71108f3b565n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d86270fd-0171-4807-944e-a0b6b4b93453n@googlegroups.com>
Subject: Re: Applications of bit manipulation functions in Fortran
From: robin.vowels@gmail.com (Robin Vowels)
Injection-Date: Mon, 09 May 2022 07:10:31 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Robin Vowels - Mon, 9 May 2022 07:10 UTC

On Monday, May 9, 2022 at 2:32:38 PM UTC+10, Walter Spector wrote:
> Prior to Fortran 77, there was no character data type.
..
Not in FORTRAN, but available in COBOL and PL/I for more than a decade.
..
> Hollerith constants were used to set character strings into numeric variables.
> String size fixed to the number of characters a 'numeric storage unit' (NSU)
> could hold.
..
> Various machines allowed packing anywhere from 2 to 10 characters per integer, and 4 to 10 characters per real.
> (The compilers with 2 characters per integer/4 characters per real didn't conform to the Standard -
> since a NSU is supposed to be the same number of bits regardless of data type.)
> Unless one restricted oneself to a single character per NSU, which could be terribly wasteful
> of memory in those days, it was hard to write portable character string handling code.
..
PL/I provided character strings of arbitrary length from 1966 -- in both fixed-length and varying-length.
An advantage of varying-length character strings in PL/I is that each element
of an array can be of different length.
..
> Bit manipulation for accessing individual characters in packed words was extremely common, non-portable, and error prone.
..
Again, bit strings of arbitrary length were available in PL/I from 1966.
..
And, like the character strings, they could be of fixed length and varying-length.
..
> Fortran 77 changed all that with its character data type. Though it took years for some programmers to update their codes to use it. There are early adopters who take advantage of new features to clean up their code, make things more reliable and easier to maintain. Then there are those who wait until the very last moment before their favorite computer system or compiler disappears and they are forced to change. Or they retire first, and their codes die after they leave because no one wants to touch the. (Then complain about it for the next 20 years on these Internet forums...)
>
> I've rarely needed to use the bit intrinsics since Fortran 77 (+ Mil Spec extensions) came out. But at least when I do, the spelling and functionality of the intrinsics are standardized now.

Re: Applications of bit manipulation functions in Fortran

<e59edf6d-6460-4306-b1e4-76fb406dd78fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:38b:b0:2f3:dcce:a7a3 with SMTP id j11-20020a05622a038b00b002f3dccea7a3mr3252537qtx.439.1652107714751;
Mon, 09 May 2022 07:48:34 -0700 (PDT)
X-Received: by 2002:a25:31c2:0:b0:641:660f:230f with SMTP id
x185-20020a2531c2000000b00641660f230fmr13569704ybx.472.1652107714612; Mon, 09
May 2022 07:48:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 9 May 2022 07:48:34 -0700 (PDT)
In-Reply-To: <d86270fd-0171-4807-944e-a0b6b4b93453n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:ccd0:bda0:db20:2a44:d583:fbb4;
posting-account=rI197goAAAC_3Br9qa3zpMvdPg0TDLVr
NNTP-Posting-Host: 2600:1700:ccd0:bda0:db20:2a44:d583:fbb4
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
<t3o428$1vq2$1@gioia.aioe.org> <e0a8db14-9ac9-4208-be4c-a71108f3b565n@googlegroups.com>
<d86270fd-0171-4807-944e-a0b6b4b93453n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e59edf6d-6460-4306-b1e4-76fb406dd78fn@googlegroups.com>
Subject: Re: Applications of bit manipulation functions in Fortran
From: w6ws@earthlink.net (Walter Spector)
Injection-Date: Mon, 09 May 2022 14:48:34 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2276
 by: Walter Spector - Mon, 9 May 2022 14:48 UTC

On Monday, May 9, 2022 at 12:10:33 AM UTC-7, Robin Vowels wrote:
> On Monday, May 9, 2022 at 2:32:38 PM UTC+10, Walter Spector wrote:
> > Prior to Fortran 77, there was no character data type.
> .
> PL/I provided character strings of arbitrary length from 1966 -- in both fixed-length and varying-length.
> An advantage of varying-length character strings in PL/I is that each element
> of an array can be of different length.
> .
> > Bit manipulation for accessing individual characters in packed words was extremely common, non-portable, and error prone.
> .
> Again, bit strings of arbitrary length were available in PL/I from 1966.

I was posting in the context of Fortran. Of course there were many languages prior to Fortran 77, dating back to the 1950s, that had character and even bit-level data types.

Re: Applications of bit manipulation functions in Fortran

<58413839-16d5-4c9b-8979-dbe9ee78db57n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ad4:5bcc:0:b0:45b:115d:b9e5 with SMTP id t12-20020ad45bcc000000b0045b115db9e5mr6361793qvt.77.1652138874549;
Mon, 09 May 2022 16:27:54 -0700 (PDT)
X-Received: by 2002:a0d:e296:0:b0:2f7:c169:126f with SMTP id
l144-20020a0de296000000b002f7c169126fmr16202201ywe.431.1652138874374; Mon, 09
May 2022 16:27:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 9 May 2022 16:27:54 -0700 (PDT)
In-Reply-To: <e59edf6d-6460-4306-b1e4-76fb406dd78fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=202.67.103.232; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le
NNTP-Posting-Host: 202.67.103.232
References: <16a16dc4-9458-43f6-b769-4a8ea6dd5c76n@googlegroups.com>
<t3o428$1vq2$1@gioia.aioe.org> <e0a8db14-9ac9-4208-be4c-a71108f3b565n@googlegroups.com>
<d86270fd-0171-4807-944e-a0b6b4b93453n@googlegroups.com> <e59edf6d-6460-4306-b1e4-76fb406dd78fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <58413839-16d5-4c9b-8979-dbe9ee78db57n@googlegroups.com>
Subject: Re: Applications of bit manipulation functions in Fortran
From: robin.vowels@gmail.com (Robin Vowels)
Injection-Date: Mon, 09 May 2022 23:27:54 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2491
 by: Robin Vowels - Mon, 9 May 2022 23:27 UTC

On Tuesday, May 10, 2022 at 12:48:36 AM UTC+10, Walter Spector wrote:
> On Monday, May 9, 2022 at 12:10:33 AM UTC-7, Robin Vowels wrote:
> > On Monday, May 9, 2022 at 2:32:38 PM UTC+10, Walter Spector wrote:
> > > Prior to Fortran 77, there was no character data type.
> > .
> > PL/I provided character strings of arbitrary length from 1966 -- in both fixed-length and varying-length.
> > An advantage of varying-length character strings in PL/I is that each element
> > of an array can be of different length.
> > .
> > > Bit manipulation for accessing individual characters in packed words was extremely common, non-portable, and error prone.
> > .
> > Again, bit strings of arbitrary length were available in PL/I from 1966.
..
> I was posting in the context of Fortran.
..
I was merely pointing out that bit strings and character strings had been available
in FORTRAN VI for more than a decade prior to F77. Of course, FORTRAN VI
was better known as PL/I.
..
> Of course there were many languages prior to Fortran 77, dating back to the 1950s,
> that had character and even bit-level data types.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor