40代からのプログラミング_(初心者奮闘記)

プログラミングに関する学習メモ

累乗(べき乗)に関してのメモ

# 「^」 この記号
# circumflex
# 合わせて覚えておくのは、superscript
# 英語で意味を調べると下記
Raises a number to the power of another number.
(raiseとpowerがキーワード)

======

c, swift

// pow(x,y) => raise x to the power of y
// cはmath.h が必要、swiftはCocoaで大丈夫

java, go

// math.Pow(x, y)
// まさにオブジェクト指向な書き方

javaScript, python, perl, ruby

// x**y
// 直感的に、すぐ計算できるのが良い
// pythonSyntax3.7.2には「powers」とシンプルに表記
https://docs.python.org/3/tutorial/introduction.html#using-python-as-a-calculator

VBA

// x^y (circumflex character)
// エラーになる場合があるそうだ、ただの演算なのに...
// ExcelのPower関数を使うのが無難
application.worksheetfunction.power(number,power)

======

各言語ごとのコンセプトが
少し分かったような気がする
(VBAは、%がModなのも謎…)