Drkcore

04 06 2009 Python fortran Tweet

限りなく小さくする

古いfortranのプログラムを読んでいたら

   EPS = 1.0
10 EPS = EPS/2.0
   S = 1.0 + EPS
   IF (S .GT. 1.0) GO TO 10

というコードをみつけて?となったがすぐに限りなく小さいの求め方か!と気がついた。

pythonだとこんな感じ

eps = 1.0
while eps+1.0 > 1.0: eps = eps/2.0 
# eps=1.1102230246251565e-16

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021