SQLite Forum

Efficiently checking if a TEXT column exclusively contains integers or floating point numbers (as strings)
See <http://www.dessus.com/files/sqlnumeric.c>

Implements a function ToBestType(x) which converts the value x passed as a parameter to its Best Type.

 - TEXT or BLOB parameter that "looks like a number" returns the number as Integer or Real as appropriate.  
 - TEXT or BLOB parameter that is zero length returns NULL.  
 - INTEGER or REAL parameter is converted to text and returns the same number in its most appropriate format (Integer or Real).  
 - Everything else returns the parameter given.