[sqlite] query REAL without trailing decimal and zero?

2014-09-15 Thread Nelson, Erik - 2
When I query a field defined with type 'real', I get '.0' appended to the 
results for whole numbers.  For example if the value in the field is 1, it 
appears as 1.0 in the query results.

Is there some way for me to change this?  I poked around in the code and it 
appeared that the format string being used was something like

sqlite3_snprintf(nByte, pMem-z, %!.15g, pMem-r);

I didn't find any documentation on what the ! character does, but the g 
format specifier seems to indicate that the decimal point and trailing zero 
ought not to be included.

http://en.wikipedia.org/wiki/Printf_format_string#Type

Any tips would be appreciated!

Erik



--
This message, and any attachments, is for the intended recipient(s) only, may 
contain information that is privileged, confidential and/or proprietary and 
subject to important terms and conditions available at 
http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended 
recipient, please delete this message.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] query REAL without trailing decimal and zero?

2014-09-15 Thread Richard Hipp
On Mon, Sep 15, 2014 at 3:02 PM, Nelson, Erik - 2 
erik.l.nel...@bankofamerica.com wrote:

 When I query a field defined with type 'real', I get '.0' appended to the
 results for whole numbers.  For example if the value in the field is 1, it
 appears as 1.0 in the query results.

 Is there some way for me to change this?


Instead of SELECT x FROM... you could enter SELECT printf('%g',x) FROM



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] query REAL without trailing decimal and zero?

2014-09-15 Thread Nelson, Erik - 2
Richard Hipp wrote on Monday, September 15, 2014 3:16 PM
 On Mon, Sep 15, 2014 at 3:02 PM, Nelson, Erik - 2 
 erik.l.nel...@bankofamerica.com wrote:
 
  When I query a field defined with type 'real', I get '.0' appended to
  the results for whole numbers.  For example if the value in the field
  is 1, it appears as 1.0 in the query results.
 
  Is there some way for me to change this?
 
 
 Instead of SELECT x FROM... you could enter SELECT printf('%g',x)
 FROM 

Yes, understood.  I was hoping to affect the default behavior and don't mind 
maintaining the patch.

--
This message, and any attachments, is for the intended recipient(s) only, may 
contain information that is privileged, confidential and/or proprietary and 
subject to important terms and conditions available at 
http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended 
recipient, please delete this message.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users