Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@hayashi-ay
Copy link
Owner

- 数値を読んでいく

INT_MAX, INT_MINを超えたらそこで終了する。Pythonのintは理論上は上限がないので途中のオーバーフローなどは考えなくて良い。
CやC++で実装する場合でも32bitより大きい型(long)を確保してあげれば考えなくて良くなる。← ただlongの場合のオーバーフローの考慮などどこかではちゃんと考慮しないといけない。その場合は、桁上りの計算をする前にオーバーフローするかどうかを判定すれば良い。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long はデータモデルによってサイズが異なります。
https://ja.wikipedia.org/wiki/64%E3%83%93%E3%83%83%E3%83%88
LP64 LLP64 等でお調べください。

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます。C++の規格では各typeの最小のbit数を規程していて、実際のサイズはその制約を満たす上で選択されたデータモデルによって決まるんですね。

C++の規格ではlongの最小サイズは32bitとして決められていて、LP32のようなデータモデルだと32bitになる。long long型については64bit以上であることが仕様上保証されている。

index += 1
return index

def get_sign(begin):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文字を解析してインデックスと符号を得ているため、 get より parse という単語を使用したほうがしっくりくると思います。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants