number format

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Re: number format

Postby sovanm » Fri Sep 13, 2013 1:33 pm

Yeah!! Javascript precision ... :D :D

We can also handle it in this way:
Code: Select all
var multiplier = Math.pow(10, places);
return (Math.round((value * multiplier).toFixed(places)) / multiplier);


Not tested for all cases though..

Thanks,
sovanm
 
Posts: 99
Joined: Fri Oct 28, 2011 1:55 pm
Location: Bhubaneswar, India

Re: number format

Postby robysimo09 » Fri Sep 13, 2013 2:19 pm

It works with all cases... Thank you!
it's incredible that I need to use this solution... :x
robysimo09
 
Posts: 108
Joined: Fri Sep 04, 2009 9:06 am

Re: number format

Postby jcompagner » Tue Sep 17, 2013 9:32 am

just a tip: if you are working with currency, then don't store a floating point like "9.94" in the database but store it as an integer in cents "994"
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: number format

Postby robysimo09 » Tue Sep 17, 2013 11:43 am

ok but in many cases I work with floating number without store.
Example: for calc the VAT. 21% of 133,43= 26,686 and sum this value with another one similar ( with 3 or + decimals ).
I need to work with all the values but if the round of all values is incorrect, i have an error at the end of operations..

I need to use the correct utils.numberFormat function that work correctly in servoy 6 and 7 but doesn't work in servoy 5.2.

Bye
Roberto
robysimo09
 
Posts: 108
Joined: Fri Sep 04, 2009 9:06 am

Previous

Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: Bing [Bot] and 7 guests

cron