Hacker News new | ask | show | jobs
by nick__m 201 days ago
2 * 1000 is 2000 ;)

I think you meant 2**1000

the syntax for formatting ate your star https://news.ycombinator.com/formatdoc

3 comments

For anyone else who, like me a moment ago, doesn't know the meaning of ** but is curious: it's how many (but not all) programming languages express "to the power of", aka 2**1000 = 2^1000
> 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

He's explaining that C was not the reason for picking * over ^
Interesting, thanks!
And != means ≠
Oh that's why i did not get any upvotes /i
Wow, I didn't know that you could write

  like
    this
      for
        code
          blocks
It’s been around since at least occam, maybe longer