I have several points against this idea: 1. Decimal or Numeric is used for to keep exact accuracy. If you don't need this accuracy use float point data types.
2. System that will produce unpredictable results in math is really hard to use. Some numbers will rounded, truncated or modified. There will lot of risk in financial calculation because real result will depend on server config. From my point of view, this auto casting will generate more problems than helps. Slavek Ing. Slavomir Skopalik Executive Head Elekt Labs s.r.o. Collection and evaluation of data from machines and laboratories by means of system MASA (http://www.elektlabs.cz/m2demo) ----------------------------------------------------------------- Address: Elekt Labs s.r.o. Chaloupky 158 783 72 Velky Tynec Czech Republic --------------------------------------------------------------- Mobile: +420 724 207 851 icq:199 118 333 skype:skopaliks e-mail:skopa...@elektlabs.cz http://www.elektlabs.cz On 7.12.2015 17:21, Carlos H. Cantu wrote: > I know there are plans to support long numbers in Firebird. I have no > idea what is the schedule for its implementation or how much this > subject has been discussed before. Anyway, this email is not to > discuss long numbers implementation, although the subject can be more > or less related. > > I want to discuss an implementation/enhancement to avoid "unnecessary" > overflow errors with calculations using currently exact types > (numeric, decimal - dialect 3). > > With currently logic, the result of multiplications or divisions will > have Scale = Sum of the scale of its members. This cause nonsense > situations like the following: > > select 1.000000000 / 1.0000000000 from rdb$database > > resulting in: > Arithmetic overflow or division by zero has occurred. arithmetic > exception, numeric overflow, or string truncation. numeric value is > out of range. > > Even if currently logic is defined by the SQL Standard, for the end > user, this is usually a pain. > > My suggestion is to implement a "smarter" logic to be used in > calculations, to avoid such glitches whenever it is possible, without > the need to create new data types. > > In short, the idea would be: do the calculation without worrying about > scale limits, and cast the final result to fit in the desired data > type. > > At a first though, I would propose that for the internal calculation > (meaning Firebird doing its internal math to give the formula result), > it should not limit the scale at all. Use the maximum possible scale > (cast/round/truncate when needed), or maybe use an IEEE format in the > intermediate calcs, to avoid overflow errors due to scale limit being > reached. If final value generated a scale that cannot fit in the > desired field/variable data type, it will be automatically casted to > it. > > For those afraid of "legacy" formulas starting to return different > results, the parser can be smart enough to apply new logic only when > needed, otherwise it would use the old (currently) logic. For > "paranoics", there could be even a parameter in fb.conf to disable new > logic at all (although, personally, I don't think this is needed). > > Currently users already need to use "workarounds" to be able to work > with those situations, meaning that some degree of accuracy is already > being lost. Usually, they will split the formula in "groups" and use > casts. Those "legacy" formulas would still work as designed, producing > the same result, since parser would use old logic. > > Comments? Ideas? Suggestions? Bashing? :) > > []s > Carlos > http://www.firebirdnews.org > FireBase - http://www.FireBase.com.br > > > ------------------------------------------------------------------------------ > Go from Idea to Many App Stores Faster with Intel(R) XDK > Give your users amazing mobile app experiences with Intel(R) XDK. > Use one codebase in this all-in-one HTML5 development environment. > Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs. > http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140 > Firebird-Devel mailing list, web interface at > https://lists.sourceforge.net/lists/listinfo/firebird-devel > ------------------------------------------------------------------------------ Go from Idea to Many App Stores Faster with Intel(R) XDK Give your users amazing mobile app experiences with Intel(R) XDK. Use one codebase in this all-in-one HTML5 development environment. Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs. http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140 Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel