spectaclehong's blog

By spectaclehong, history, 7 years ago, In English
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
7 years ago, # |
Rev. 2   Vote: I like it +11 Vote: I do not like it

1e19 is of type double, and for the ternary operator types must match, thus the return value of dfs is cast to double. Double can't represent every integer value up to 10^19 precisely, thus the error, I think.

edit: you could also declare 1e19 as a long double (1e19L), which can represent every int up to 10^19 precisely (at least on most systems) 34050510