On 2015/01/19 12:52, Stephan Buchert wrote:
(Prompt erased for easier paste and copy):

CREATE TABLE satpos(msec INTEGER, latitude REAL, longitude REAL);
INSERT INTO satpos VALUES (86386217,-0.0318895369716216,-167.689719869132);
INSERT INTO satpos VALUES
(86386716,-2.93238037697483e-06,-167.690497310632);
INSERT INTO satpos VALUES (86387217,0.0319616241531195,-167.69127664905);
SELECT * FROM satpos;
86386217|-0.0318895369716216|-167.689719869132
86386716|-2.93238037697483e-06|-167.690497310632
86387217|0.0319616241531195|-167.69127664905

So far, so good, but:

.mode column
.width -8 -7 -8
SELECT * FROM satpos;
86386217  -0.0318  -167.689
86386716  -2.9323  -167.690
86387217  0.03196  -167.691

In the 2nd row, 2nd column "-0.0000" or "-2.9e-6" would make me happy. But
"-2.9323" definitely messes up my stuff.

The width specifier is simply a cut-off style formatter. Two solutions to get the correct anwer listed below, pic the one that suits you -

================================================================================================
CREATE TABLE satpos(msec INTEGER, latitude REAL, longitude REAL);
INSERT INTO satpos VALUES (86386217,-0.0318895369716216,-167.689719869132);
INSERT INTO satpos VALUES (86386716,-2.93238037697483e-06,-167.690497310632);
INSERT INTO satpos VALUES (86387217,0.0319616241531195,-167.69127664905);

SELECT msec, round(latitude,6), round(longitude,6) FROM satpos;
------------------------------------------------------------------------------------------------
msec    round(latitude,6)    round(longitude,6)
86386217    -0.03189    -167.68972
86386716    -3.0e-06    -167.690497
86387217    0.031962    -167.691277

 SELECT msec, printf('%12.3f',latitude), printf('%12.3f',longitude) FROM satpos;
------------------------------------------------------------------------------------------------
msec    printf('%12.3f',latitude)    printf('%12.3f',longitude)
86386217          -0.032        -167.690
86386716          -0.000        -167.690
86387217           0.032        -167.691


================================================================================================

  Script Stats: Total Script Execution Time:     0d 00h 00m and 00.049s
                Total Script Query Time:         0d 00h 00m and 00.005s
                Total Database Rows Changed:     3
                Total Virtual-Machine Steps:     141
                Last executed Item Index:        6
                Last Script Error:
------------------------------------------------------------------------------------------------
2015-01-19 14:22:02.197  |  [Success]    Script Success.
2015-01-19 14:22:04.959  |  [Success]    Transaction Rolled back.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to