2019-11-15 19:07:12 -0600 | commented question | Different results with for loop and while loop Related question: https://ask.sagemath.org/question/307... |

2019-11-15 16:38:34 -0600 | answered a question | Different results with for loop and while loop Figured out the the reason as well: with the type of On the other hand, with the type of |

2019-11-15 16:35:56 -0600 | asked a question | Different results with for loop and while loop While writing a Sage script, I ran into a strange case where code worked correctly with specific constants, but when I looped over them in a Here's the code: In short, the problem is that |

2016-02-17 12:30:11 -0600 | received badge | ● Famous Question (source) |

2016-01-30 20:27:23 -0600 | received badge | ● Notable Question (source) |

2016-01-29 17:56:06 -0600 | received badge | ● Popular Question (source) |

2016-01-29 10:46:21 -0600 | received badge | ● Scholar (source) |

2016-01-29 10:46:17 -0600 | commented answer | Incorrect result for comparison (precision issues?) I also tried this |

2016-01-29 10:20:49 -0600 | commented answer | Incorrect result for comparison (precision issues?) Very useful; thank you very much! I'll use this (will also mark this answer as accepted). But I'm wondering why |

2016-01-29 07:59:36 -0600 | received badge | ● Student (source) |

2016-01-29 01:24:29 -0600 | commented question | Incorrect result for comparison (precision issues?) This is extremely odd: but the correct value is (with But the odd part is that if I try log(1024)/log(10) * 82553493450 - 248510777753 > 0 http://www.wolframalpha.com/input/?i=log%281024%29%2Flog%2810%29+*+82553493450+-+248510777753+%3E+0 (on Wolfram Alpha) it correctly says True, but shows the approximate form of the difference as exactly the same wrong value: -0.0000610352 !! How are both Sage and Wolfram Alpha getting to the same wrong answer? |

2016-01-29 01:10:23 -0600 | commented question | Incorrect result for comparison (precision issues?) Trying "arbitrary precision" doesn't help either: or: both return False, versus which correctly returns True. It's beginning to look like a bug in Sage's |

2016-01-29 00:05:28 -0600 | asked a question | Incorrect result for comparison (precision issues?) Consider this session: or more simply: But this is wrong, as we can see with higher-precision arithmetic: I guess this is happening because Sage is computing to some finite precision. But when writing some bigger program, it's scary that a condition involving variables, like say, can without warning give the wrong result and take the wrong path. Is there a way to prevent this from happening, i.e. to make sure that in the program, comparisons are done using as many bits of precision as are necessary to evaluate them correctly, without us having to pre-specify a precision (which may be both too large and wasteful, or too small and give incorrect results)? |

2014-01-22 19:12:21 -0600 | received badge | ● Supporter (source) |

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.