using an optimally-precise Pow: 1: rounded = 1, both = 1.00000000000000000000, delta = +0.00000000000000000000e+00 2: rounded = 1, both = 1.00000000000000000000, delta = +0.00000000000000000000e+00 3: rounded = 2, both = 2.00000000000000000000, delta = +0.00000000000000000000e+00 4: rounded = 3, both = 3.00000000000000000000, delta = +0.00000000000000000000e+00 5: rounded = 5, both = 5.00000000000000000000, delta = +0.00000000000000000000e+00 6: rounded = 8, both = 8.00000000000000000000, delta = +0.00000000000000000000e+00 7: rounded = 13, both = 13.00000000000000000000, delta = +0.00000000000000000000e+00 8: rounded = 21, both = 21.00000000000000000000, delta = +0.00000000000000000000e+00 9: rounded = 34, both = 34.00000000000000000000, delta = +0.00000000000000000000e+00 10: rounded = 55, both = 55.00000000000000000000, delta = +0.00000000000000000000e+00 11: rounded = 89, both = 89.00000000000000000000, delta = +0.00000000000000000000e+00 12: rounded = 144, both = 144.00000000000000000000, delta = +0.00000000000000000000e+00 13: rounded = 233, both = 233.00000000000000000000, delta = +0.00000000000000000000e+00 14: rounded = 377, both = 377.00000000000005684342, delta = +5.68434188608080148697e-14 15: rounded = 610, both = 610.00000000000000000000, delta = +0.00000000000000000000e+00 16: rounded = 987, both = 986.99999999999977262632, delta = -2.27373675443232059479e-13 17: rounded = 1597, both = 1596.99999999999977262632, delta = -2.27373675443232059479e-13 18: rounded = 2584, both = 2584.00000000000000000000, delta = +0.00000000000000000000e+00 19: rounded = 4181, both = 4181.00000000000000000000, delta = +0.00000000000000000000e+00 20: rounded = 6765, both = 6765.00000000000090949470, delta = +9.09494701772928237915e-13 21: rounded = 10946, both = 10946.00000000000363797881, delta = +3.63797880709171295166e-12 22: rounded = 17711, both = 17711.00000000000000000000, delta = +0.00000000000000000000e+00 23: rounded = 28657, both = 28657.00000000000363797881, delta = +3.63797880709171295166e-12 24: rounded = 46368, both = 46368.00000000000727595761, delta = +7.27595761418342590332e-12 25: rounded = 75025, both = 75025.00000000001455191523, delta = +1.45519152283668518066e-11 26: rounded = 121393, both = 121393.00000000001455191523, delta = +1.45519152283668518066e-11 27: rounded = 196418, both = 196418.00000000005820766091, delta = +5.82076609134674072266e-11 28: rounded = 317811, both = 317811.00000000011641532183, delta = +1.16415321826934814453e-10 29: rounded = 514229, both = 514228.99999999994179233909, delta = -5.82076609134674072266e-11 30: rounded = 832040, both = 832040.00000000000000000000, delta = +0.00000000000000000000e+00 31: rounded = 1346269, both = 1346269.00000000046566128731, delta = +4.65661287307739257812e-10 32: rounded = 2178309, both = 2178309.00000000000000000000, delta = +0.00000000000000000000e+00 33: rounded = 3524578, both = 3524577.99999999906867742538, delta = -9.31322574615478515625e-10 34: rounded = 5702887, both = 5702886.99999999906867742538, delta = -9.31322574615478515625e-10 35: rounded = 9227465, both = 9227465.00000000000000000000, delta = +0.00000000000000000000e+00 36: rounded = 14930352, both = 14930352.00000000000000000000, delta = +0.00000000000000000000e+00 37: rounded = 24157817, both = 24157816.99999999254941940308, delta = -7.45058059692382812500e-09 38: rounded = 39088169, both = 39088169.00000000000000000000, delta = +0.00000000000000000000e+00 39: rounded = 63245986, both = 63245986.00000000745058059692, delta = +7.45058059692382812500e-09 40: rounded = 102334155, both = 102334155.00000002980232238770, delta = +2.98023223876953125000e-08 41: rounded = 165580141, both = 165580141.00000002980232238770, delta = +2.98023223876953125000e-08 42: rounded = 267914296, both = 267914296.00000014901161193848, delta = +1.49011611938476562500e-07 43: rounded = 433494437, both = 433494437.00000011920928955078, delta = +1.19209289550781250000e-07 44: rounded = 701408733, both = 701408733.00000023841857910156, delta = +2.38418579101562500000e-07 45: rounded = 1134903170, both = 1134903170.00000047683715820312, delta = +4.76837158203125000000e-07 46: rounded = 1836311903, both = 1836311903.00000071525573730469, delta = +7.15255737304687500000e-07 47: rounded = 2971215073, both = 2971215072.99999904632568359375, delta = -9.53674316406250000000e-07 48: rounded = 4807526976, both = 4807526976.00000190734863281250, delta = +1.90734863281250000000e-06 49: rounded = 7778742049, both = 7778742049.00000286102294921875, delta = +2.86102294921875000000e-06 50: rounded = 12586269025, both = 12586269025.00000572204589843750, delta = +5.72204589843750000000e-06 51: rounded = 20365011074, both = 20365011074.00000762939453125000, delta = +7.62939453125000000000e-06 52: rounded = 32951280099, both = 32951280099.00001144409179687500, delta = +1.14440917968750000000e-05 53: rounded = 53316291173, both = 53316291173.00003051757812500000, delta = +3.05175781250000000000e-05 54: rounded = 86267571272, both = 86267571272.00003051757812500000, delta = +3.05175781250000000000e-05 55: rounded = 139583862445, both = 139583862445.00006103515625000000, delta = +6.10351562500000000000e-05 56: rounded = 225851433717, both = 225851433717.00018310546875000000, delta = +1.83105468750000000000e-04 57: rounded = 365435296162, both = 365435296162.00024414062500000000, delta = +2.44140625000000000000e-04 58: rounded = 591286729879, both = 591286729878.99987792968750000000, delta = -1.22070312500000000000e-04 59: rounded = 956722026041, both = 956722026041.00073242187500000000, delta = +7.32421875000000000000e-04 60: rounded = 1548008755920, both = 1548008755920.00024414062500000000, delta = +2.44140625000000000000e-04 61: rounded = 2504730781961, both = 2504730781960.99902343750000000000, delta = -9.76562500000000000000e-04 62: rounded = 4052739537881, both = 4052739537881.00341796875000000000, delta = +3.41796875000000000000e-03 63: rounded = 6557470319842, both = 6557470319842.00585937500000000000, delta = +5.85937500000000000000e-03 64: rounded = 10610209857723, both = 10610209857722.99804687500000000000, delta = -1.95312500000000000000e-03 65: rounded = 17167680177565, both = 17167680177564.99609375000000000000, delta = -3.90625000000000000000e-03 66: rounded = 27777890035288, both = 27777890035287.99218750000000000000, delta = -7.81250000000000000000e-03 67: rounded = 44945570212853, both = 44945570212852.99218750000000000000, delta = -7.81250000000000000000e-03 68: rounded = 72723460248141, both = 72723460248140.98437500000000000000, delta = -1.56250000000000000000e-02 69: rounded = 117669030460994, both = 117669030460993.98437500000000000000, delta = -1.56250000000000000000e-02 70: rounded = 190392490709135, both = 190392490709135.00000000000000000000, delta = +0.00000000000000000000e+00 71: rounded = 308061521170129, both = 308061521170129.18750000000000000000, delta = +1.87500000000000000000e-01 72: rounded = 498454011879264, both = 498454011879264.00000000000000000000, delta = +0.00000000000000000000e+00 73: rounded = 806515533049393, both = 806515533049393.12500000000000000000, delta = +1.25000000000000000000e-01 74: rounded = 1304969544928657, both = 1304969544928656.50000000000000000000, delta = -5.00000000000000000000e-01 75: rounded = 2111485077978050, both = 2111485077978050.00000000000000000000, delta = +0.00000000000000000000e+00 76: rounded = 3416454622906708, both = 3416454622906707.50000000000000000000, delta = -5.00000000000000000000e-01 77: rounded = 5527939700884756, both = 5527939700884756.00000000000000000000, delta = +0.00000000000000000000e+00 78: rounded = 8944394323791466, both = 8944394323791466.00000000000000000000, delta = +0.00000000000000000000e+00 79: rounded = 14472334024676214, both = 14472334024676214.00000000000000000000, delta = +0.00000000000000000000e+00 80: rounded = 23416728348467700, both = 23416728348467700.00000000000000000000, delta = +0.00000000000000000000e+00 81: rounded = 37889062373143904, both = 37889062373143904.00000000000000000000, delta = +0.00000000000000000000e+00 82: rounded = 61305790721611608, both = 61305790721611608.00000000000000000000, delta = +0.00000000000000000000e+00 83: rounded = 99194853094755536, both = 99194853094755536.00000000000000000000, delta = +0.00000000000000000000e+00 84: rounded = 160500643816367264, both = 160500643816367264.00000000000000000000, delta = +0.00000000000000000000e+00 85: rounded = 259695496911122752, both = 259695496911122752.00000000000000000000, delta = +0.00000000000000000000e+00 86: rounded = 420196140727489984, both = 420196140727489984.00000000000000000000, delta = +0.00000000000000000000e+00 87: rounded = 679891637638612608, both = 679891637638612608.00000000000000000000, delta = +0.00000000000000000000e+00 88: rounded = 1100087778366102528, both = 1100087778366102528.00000000000000000000, delta = +0.00000000000000000000e+00 89: rounded = 1779979416004716032, both = 1779979416004716032.00000000000000000000, delta = +0.00000000000000000000e+00 90: rounded = 2880067194370818048, both = 2880067194370818048.00000000000000000000, delta = +0.00000000000000000000e+00 91: rounded = 4660046610375532544, both = 4660046610375532544.00000000000000000000, delta = +0.00000000000000000000e+00 92: rounded = 7540113804746352640, both = 7540113804746352640.00000000000000000000, delta = +0.00000000000000000000e+00
On Mon, Apr 30, 2018 at 2:40 PM andrey mirtchovski <mirtchov...@gmail.com> wrote: > > math.Pow does not give as precise answers as the C++ std lib. > > math pow doesn't just multiply X by itself Y times, it uses a > different algorithm: > > https://golang.org/src/math/pow.go#L40 > > it would perhaps make sense to quantify the error margins that this > algorithm introduces. > > not sure what c++ stdlib does. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Michael T. Jones michael.jo...@gmail.com -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.