Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Can the toString() function format numbers according to their type? #575

Closed
jphillips-bp3 opened this issue Mar 14, 2019 · 3 comments
Closed
Labels
0.20 Type: Bug 🐛 Something isn't working Type: Feature Request 🛍️ New feature or request

Comments

@jphillips-bp3
Copy link

I am using the toString function to turn a Long type into a String. For example when I call toString(myDate.getYear()) it returns 2019.0 instead of just 2019. I have tried this on an Integer and get a decimal place tacked onto the end of it as well.

Would it be possible for toString to be type aware and format numerical types appropriately?

@jeromesimeon
Copy link
Member

That's a good request, and even could be considered a bug.

@jeromesimeon jeromesimeon added Type: Bug 🐛 Something isn't working Type: Feature Request 🛍️ New feature or request labels Mar 14, 2019
@jeromesimeon
Copy link
Member

A fix for this is being worked on in the "Dynamic Templates" branch https://github.com/accordproject/ergo/tree/js-feature-dynamic-templates

This fix relies on the ability to distinguish between Integer and Double in the JavaScript runtime.

@jeromesimeon
Copy link
Member

Fixed in the 0.20 branch. Test here in the REPL:

Screenshot 2019-10-14 at 3 19 25 PM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
0.20 Type: Bug 🐛 Something isn't working Type: Feature Request 🛍️ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants