I'm voting for putting all your notes somewhere very easy to find in the future and then leaving everything the way it has been working.
This way, we can start up where you left off if necessary and, otherwise, continue on with more pressing issues. Thanks, Trevor On Thu, Sep 11, 2014 at 9:12 PM, Henrik Lindberg < henrik.lindb...@cloudsmith.com> wrote: > Hi, > Instead of continuing on the old thread "A question about numbers and > representation", I decided to open a new thread avout BigDecimal to see if > we can come to closure on that separately. > > Digging a bit more into Ruby, and how it handles floating point reveals > that there is in fact no automatic fluent transition to BigDecimal. All > floating point calculations are performed with the native double > representation on the platform ruby is executing on. Since Puppet does not > create any BigDecimal numbers no one has ever been able to create a value > with higher precision in Puppet than what the native double provides > (unless doing so in custom Ruby functions I should add). > > Integer representation is in contrast fluently transformed between a a > native fixed (long) and big integer representation. > > Thus, the puppet language specification is currently wrong as it states > that Puppet's floating point fluently transforms. > > The implementation difficulties with BigInteger can be handled both in > serialization and in PuppetDB; not without possible performance issues, but > still quite doable. But lets leave that for another later thread. > > If we however want to add support for BigDecimal a lot more work is > required simply because this must be exposed to the Puppet programmer or we > will be using BigDecimals with a preset precision. We could possibly create > BigDecimals if > 15 value digits are entered, but it would mean using > something like 1.00000000000000000000 if you wanted 22 digits precision (if > I counted correctly :-)). > > Having some sort of fluent handling of BigDecimals would also require that > all inputs in string form are parsed and turned into a floating point > number the same way (or we will lose precision there). > > The biggest hurdle is dealing with scale, precision and rounding. > Typically this is specified in a math context that is passed when > performing each operation. This can not be done on a global basis as that > just sets another fixed limit. If the global math context is > shareable/writeable, no one can trust the precision of the calculations as > someone else could have changed the context. Thus, a global context would > have to be always set before using it... (horrible). > > Thus, the only reasonable way of handling BigDecimals is as a set of > functions for creating them with a given precision, handle operations like > add, divide, multiply, etc. and passing around a hash that describes the > math context. > > I seriously doubt the effort of implementing this will pay off. There has > been no requests for it (we would not be having this discussion unless I > started talking about numeric representation), the only floating point use > in puppet manifests that I have seen are for very simple calculations. > Finally, the domain of floating point calculations has such a great > complexity that I think is not suitable for neither the Puppet Language nor > its users. > > What I can imagine though are special data types if they are indeed needed > (i.e. something with a given fixed precision, and given rounding rules). > The one that typically comes up is the type Money, but that is not > something that I expect to be used much in Puppet. > > Given all the above, I think we should simply stick with the native double > for floating point the same way it is implemented and has been working all > along. > > - henrik > -- > > Visit my Blog "Puppet on the Edge" > http://puppet-on-the-edge.blogspot.se/ > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-dev+unsubscr...@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/puppet-dev/luthal%247p1%241%40ger.gmane.org. > For more options, visit https://groups.google.com/d/optout. > -- Trevor Vaughan Vice President, Onyx Point, Inc (410) 541-6699 tvaug...@onyxpoint.com -- This account not approved for unencrypted proprietary information -- -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoV%2B%3Dz4EZi7d5hu4pmbOoV_oTBD87rn05AKvqPZZPY%2Bhbg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.