Monday 8 September 2008

Oh Fortran, how I love thee.

Fortran's logical operators that operate on integers happen to be bitwise. I didn't care about this until now. Here's a summary for two integers, a and b, which can take values 0 or 1.

logical AND:






(ab)iand(a,b)
000
010
100
111

logical OR:






(ab)ior(a,b)
000
011
101
111

logical XOR:






(ab)ieor(a,b)
000
011
101
110

logical NOT:




(a)not(a)
0-1
1-2

WTF? I have been bitten by the bitwise bear! In order to get zeros and ones, I must use ieor(1,a) instead of not(a). Pah.

Also, the tables in this post look all shit in my browser but I can't be bothered to fix them when I have Fortran to do instead.

Today's post was brought to you by the numbers 0 and 1 and the letter F.

No comments: