On Sat, Jan 02, 2010 at 10:01:42AM +0000, Simon Slavin scratched on the wall:
> 
> On 2 Jan 2010, at 9:54am, Bert Nelsen wrote:
> 
> > I am trying to save values like 19.000.000.000 to my database but I haven't
> > found the appropriate column type yet. Can anybody help please.
> > I am using the dhRichClient command object, but even Int64 isn't large
> > enough.

> If you need values that large you can't use INTEGER.

  Yes you can.  That number isn't all that big.
  
  As the link you posted says, integers in SQLite auto scale to 64 bits. 
  That's -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.  
  
  The number 19,000,000,000 only requires 36 bits of signed space,
  meaning SQLite will store it as an integer in only 5 bytes.

> If you need precision to the 1 then you can't use REAL. 

  Again, yes you can.  SQLite uses 64 bit floats.  These offer up to 52
  bits (53 normalized) bits of representation while keeping 1 bit
  precision (i.e. integer precision).  Since the sign is stored
  elsewhere with floats, we only need 35 of those bits.


  More to the point:

sqlite> CREATE TABLE t ( i INTEGER, r REAL );
sqlite> INSERT INTO t VALUES ( 19000000000, 19000000000 );
sqlite> INSERT INTO t VALUES ( 19000000001, 19000000001 );
sqlite> INSERT INTO t VALUES ( 19000000000.0, 19000000000.0 );
sqlite> INSERT INTO t VALUES ( 19000000001.0, 19000000001.0 );
sqlite> SELECT * FROM t;
19000000000|19000000000.0
19000000001|19000000001.0
19000000000|19000000000.0
19000000001|19000000001.0

  No problem.


  It should also be noted that SQLite does not follow
  internationalizations and always uses the character "." as the
  radix point.  See: http://www.sqlite.org/lang_expr.html (Literal Values)

  If you're having other problems, I'd suspect the wrapper you're using
  is messing with the values before they get to the database.

    -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
 a protractor."   "I'll go home and see if I can scrounge up a ruler
 and a piece of string."  --from Anathem by Neal Stephenson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to