So does Roger's function work on the larger list? Let's see: (4 : '13|x*y') / 10 # 19 29 59 79 89 109 119 139 149 179 199
9 That looks like it does. Let's check with extended precision: (4 : '13|x*y') / 10 # 19 29 59 79 89 109 119 139 149 179 199x 9 So Roger's approach works without extended precision. But mine doesn't: 13| */13|/ 10 # 19 29 59 79 89 109 119 139 149 179 199 0 Let's see why. Here's Roger's verb. We'll call it 'g': g=. 4 : '13|x*y' Roger does g/ which puts g between each integer. Let's see what is going on In the short case: 19 g 29 g 59 g 79 g 89 g 109 g 119 g 139 g 149 g 179 g 199 4 Step-by-step... 179 g 199 1 149 g 1 6 139 g 6 2 119 g 2 4 109 g 4 7 89 g 7 12 79 g 12 12 59 g 12 6 29 g 6 5 19 g 5 4 So the secret is that Roger's scheme keeps the interim calculation values small enough to avoid precision errors. (There's got to be an easier way to list the interim values of insert). My scheme generated large interim values which exceeded the precision limit. Skip I get a set of numbers from a database. The Skip Cave Cave Consulting LLC On Mon, Sep 18, 2017 at 2:51 PM, Skip Cave <s...@caveconsulting.com> wrote: > Roger said: > > But if the list were longer: > 13 | */ 13 | 10 # 19 29 59 79 89 109 119 139 149 179 199 > 0 > > Wow! Yes I see the problem. It would be really nice if J would output a > warning when a calculation exceeds the precision limits. I'm sure this > would probably slow down all computations, so having a global variable to > turn on precision errors would be a conservative approach. > > Of course, I can usually check to see if an error has occurred by turning > on extended precision to see if the answers match, but it would be nice to > know without having to always double check my calculations.. > > 13|*/13|/ 10 # 19 29 59 79 89 109 119 139 149 179 199x > > 9 > > > Skip Cave > Cave Consulting LLC > > On Mon, Sep 18, 2017 at 1:46 PM, Roger Hui <rogerhui.can...@gmail.com> > wrote: > >> Your solution works only because the list isn't too long, and the initial >> 13| (same as 13 |/) made them all small enough that you can do the */ >> without losing precision. But if the list were longer: >> >> 13 | */ 13 | 10 # 19 29 59 79 89 109 119 139 149 179 199 >> 0 >> >> If it makes it more understandable, use explicit defn: >> >> (4 : '13|x*y') / 19 29 59 79 89 109 119 139 149 179 199 >> 4 >> >> "Multiplication mod m" means m|x*y, multiply, then take the remainder of >> division by m. >> >> >> >> ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm