Message246057
| Author | steven.daprano |
|---|---|
| Recipients | Serge Anuchin, mark.dickinson, rhettinger, steven.daprano |
| Date | 2015-07-02.03:54:00 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1435809241.84.0.449103093404.issue24546@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
Your example of int(0.99999999999999995) returning 1 is misleading, because 0.999...95 is already 1.0. (1.0 - 1/2**53) = 0.9999999999999999 is the nearest float distinguishable from 1.0. It seems to me that either random() may return 1.0 exactly (although I've never seen it) or that 0.9999999999999999*len(s) rounds up to len(s), which I guess is more likely. Sure enough, that first happens with a string of length 2049: py> x = 0.9999999999999999 py> for i in range(1, 1000000): ... if int(i*x) == i: ... print i ... break ... 2049 However your string has length 35, and it certainly doesn't happen there: py> int(x*len(s)) 34 |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2015-07-02 03:54:01 | steven.daprano | set | recipients: + steven.daprano, rhettinger, mark.dickinson, Serge Anuchin |
| 2015-07-02 03:54:01 | steven.daprano | set | messageid: <1435809241.84.0.449103093404.issue24546@psf.upfronthosting.co.za> |
| 2015-07-02 03:54:01 | steven.daprano | link | issue24546 messages |
| 2015-07-02 03:54:00 | steven.daprano | create | |