Integer displayed as a double

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

Integer displayed as a double

Postby maria.kyselova » Fri Nov 30, 2012 4:32 am

Hi guys,

Not sure whether it's a bug.
Ah well, I have a column that is defined as integer in both the physical database and Servoy .dbi file.
The column goes into a calculation of type 'TEXT' that returns something like this: aStringPrefix + integerNumber + aStringSuffix.
All good unless either prefix or suffix are null. Then the calc returns 1.0 though integerNumber value is 1.

Otherwise works fine and if I set the prefix/suffix to an empty string then all is good too.

Cheers,
Maria
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am

Re: Integer displayed as a double

Postby jcompagner » Fri Nov 30, 2012 6:27 pm

the problem is that in javascript all numbers are double's (floating point)
If you use the number to concat with a string, then you need to "format" the number look at Number.toFixed() for example
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Integer displayed as a double

Postby maria.kyselova » Sun Dec 02, 2012 11:49 am

jcompagner wrote:the problem is that in javascript all numbers are double's (floating point)
If you use the number to concat with a string, then you need to "format" the number look at Number.toFixed() for example


Interesting - when I concatenate it there is no issue with the decimal point.
It's only when the strings are null.

Cheers,
Maria
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am

Re: Integer displayed as a double

Postby ptalbot » Sun Dec 02, 2012 5:43 pm

If the string is null, then it 'assumes' an addition, so aNullString + aDouble, will give you a double.
Where aNonNullString + aDouble concatenates.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 13 guests

cron