Preferences

> 2**1000 = 2^1000

The reason for using `**` is that `^` is widely used for bitwise exclusive-or. So commonly `2**1000 != 2^1000`!


I think Fortran used ** because EBCDIC didn't have ^ or uparrow. ABC and Python followed Fortran rather than C on this point. units(1) supports both.
BCD, actually, given that Fortran dates from the mid-1950s. EBCDIC only appeared more or less around Fortran IV, in the early 1960s. Many printers in those days had a 48-character chain/train. After upper-case letters, digits, and a few essential punctuation marks (like . and ,), you weren't left with many options. The 60-character set of PL/I was a luxury back then, let alone lower case.
Hmm, I guess you're right. Also EBCDIC does have ^ apparently, though not ↑: https://en.wikipedia.org/wiki/EBCDIC#Code_page_layout

But IBM's BCD character sets, including the 48-character ones you allude to, didn't: https://en.wikipedia.org/wiki/BCD_(character_encoding)#Examp... (though Honeywell's did)

There are a lot of decisions in Fortran that stem from the absence of useful characters. .LT., .LE., .EQ., .NE., .GT., and .GE. is another.

C uses ^ for bitwise xor and a function for exponentiation, though.
No, C does not have an exponentiation operator! Possibly you meant "and not a function for exponentiation".

I should have said "followed Fortran rather than BASIC".

I meant exactly what I said. C uses a function for exponentiation. Nothing that uses ^ for powers follows C's lead.

https://en.cppreference.com/w/c/numeric/math/pow.html

Oh, I interpreted "a function for exponentiation" as being part of a list of things C uses ^ for. It didn't even occur to me that the sentence had an alternative parsing where it was part of a list of things C uses. C does indeed use a function for exponentiation. And time flies like an arrow!
He's explaining that C was not the reason for picking * over ^
Interesting, thanks!
And != means ≠

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal