Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 10 of 15 total |
money calculations |
Thu, Jun 11 2015 11:31 AM | Permanent Link |
Mike consultant | Does EWB support the currency delphi type?
One thing ive run into with JS is the number type isn't very useful for financial calculations |
Thu, Jun 11 2015 11:59 AM | Permanent Link |
Matthew Jones | Michael Margerum wrote:
> Does EWB support the currency delphi type? > > One thing ive run into with JS is the number type isn't very useful > for financial calculations No. Javascript only has "number" which is a floating point value, but EWB does type safe calculations so long as you don't pass values in from external javascript. I use Integer values of "pence" in my web shop, and it all works just fine. -- Matthew Jones |
Thu, Jun 11 2015 2:24 PM | Permanent Link |
Mike consultant | On 6/11/15 11:59 AM, Matthew Jones wrote:
> Michael Margerum wrote: > >> Does EWB support the currency delphi type? >> >> One thing ive run into with JS is the number type isn't very useful >> for financial calculations > > No. Javascript only has "number" which is a floating point value, but > EWB does type safe calculations so long as you don't pass values in > from external javascript. I use Integer values of "pence" in my web > shop, and it all works just fine. > yeh im doing math using my own routeines and ints but it would be awesome if tim could build in currency support since a lot of his users would be LOB app builders. i didnt believe it when i type .1 + .2 in JS bin and got back 0.30000000000000004 |
Fri, Jun 12 2015 4:26 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Michael,
<< yeh im doing math using my own routeines and ints but it would be awesome if tim could build in currency support >> I can't really build in currency support to an underlying language that I don't control (JS), at least not without some serious performance implications. The only thing you can do is use rounding judiciously so that you always end up with the number of decimal places that you want, and you don't accumulate floating-point rounding errors. Tim Young Elevate Software www.elevatesoft.com |
Sat, Jun 13 2015 4:20 PM | Permanent Link |
Mike consultant | > The only thing you can do is use rounding judiciously so that you always > end up with the number of decimal places that you want, and you don't > accumulate floating-point rounding errors. > > Tim Young > Elevate Software > www.elevatesoft.com Tim, i'd gladly take a hit on performance to use a pascal currency type that calls underlying JS libs to do all of this rounding. It wouldn't need to impact the single type. That could continue using the underlying javascript number type. Just my 2 cents. |
Mon, Jun 15 2015 4:14 AM | Permanent Link |
Matthew Jones | Michael Margerum wrote:
> i'd gladly take a hit on performance to use a pascal currency type > that calls underlying JS libs to do all of this rounding. Nothing to stop you doing your own then! 8-) -- Matthew Jones |
Tue, Jun 16 2015 7:46 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Michael,
<< Tim, i'd gladly take a hit on performance to use a pascal currency type that calls underlying JS libs to do all of this rounding. It wouldn't need to impact the single type. That could continue using the underlying javascript number type. Just my 2 cents. >> If you're talking about a custom compiler type, then that is a lot of work away from being a reality. There is a *lot* of code that would be required to support such a beast, especially in terms of the JS that is emitted (the type-checking for basic types like this is relatively easy). Tim Young Elevate Software www.elevatesoft.com |
Wed, Jun 17 2015 9:08 AM | Permanent Link |
Mike consultant | On 6/15/15 4:14 AM, Matthew Jones wrote:
> Michael Margerum wrote: > >> i'd gladly take a hit on performance to use a pascal currency type >> that calls underlying JS libs to do all of this rounding. > > Nothing to stop you doing your own then! 8-) > Sure I can write anything. I could probably even write my own JS transpiler but why would I when Tim is doing such an excellent job. I was just throwing it out there that it would be nice if a pascal web product supported the currency type. I understand it's probably a lot of work, but i'd bet almost every single user of this product is doing money calculations since Delphi's sweet spot is LOB apps and its a pain point I already encountered. there's lots of other things that are probably more important and I totally understand. Just throwing it on the wish list. |
Wed, Jun 17 2015 9:09 AM | Permanent Link |
Mike consultant | > If you're talking about a custom compiler type, then that is a lot of > work away from being a reality. There is a *lot* of code that would be > required to support such a beast, especially in terms of the JS that is > emitted (the type-checking for basic types like this is relatively easy). > Understood. thanks tim. I'm looking forward to trying out EWB 2 when it ships! |
Wed, Jun 17 2015 10:46 AM | Permanent Link |
Matthew Jones | The key is what do you really require? The core number type you have in
Javascript is a floating point number, so can suffer inaccuracy. There's nothing you can do really to improve it, but using EWB and the Integer type ensures it stays as an integer. By using "Cents" instead of dollars, you never have to go to floating point, other than for formatting and input. If you must have floating point, then it wouldn't be hard to do a class that works with strings, or even two integers. I note though that Javascript users seem okay with the plain floating point, as per http://openexchangerates.github.io/accounting.js/ though http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-mo ney-in-javascript has the comment of "never use floating point for currency", which is where I come in. I don't think EWB needs anything more - I have accurate currency in my web shop, and I've not had any funny values from adding tax etc. -- Matthew Jones |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Sunday, May 19, 2024 at 08:46 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |