in

System.Data.SQLite

An open-source, enhanced version of the SQLite database engine for Windows

What datatype should i use for representing a number with a floating point? (float, double..)

Last post 02-29-2008 6:46 PM by linc. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-28-2008 11:57 PM

    • linc
    • Top 75 Contributor
    • Joined on 10-26-2007
    • Posts 9

    What datatype should i use for representing a number with a floating point? (float, double..)

    Hello everyone,

    I'm having some trouble getting a float value out of a table.

    Although i can add a floating point value correctly (ex: 0.5) and see the correct value using a tool like SQLite Database Browser, i always

    get value "0.0" when i read it from my application.

     

     I have tried:

    double myvalue = Convert.toDouble(reader[0]);

    double myvalue = (float)Convert.toDouble(reader[0]);

    float myvalue = (float)myvalue = Convert.toDouble(reader[0]);

    and also tried altering the table field from "double" to "float" but it doesn't seem to work!

     

    Does anybody know what the problem seems to be?


    Thanks in advance,

    Luís Silva 

    Filed under: ,
  • 02-29-2008 2:46 AM In reply to

    • linc
    • Top 75 Contributor
    • Joined on 10-26-2007
    • Posts 9

    Re: What datatype should i use for representing a number with a floating point? (float, double..)

    Oh k! I've found the solution on another thread! Sorry ;o)

    For who might end up in this thread,  we have to be careful not to insert comma delimited values instead of "."

    ex: 0,5 is bad but 0.5 is good! ;o)

    Best,

    Luís 

  • 02-29-2008 1:20 PM In reply to

    Re: What datatype should i use for representing a number with a floating point? (float, double..)

    Are your regional settings set to allow the comma as the decimal symbol?  Alhough, importing from a CSV file may present some problems, I was under the impression that SQLite would allow for differing locale settings.

  • 02-29-2008 6:46 PM In reply to

    • linc
    • Top 75 Contributor
    • Joined on 10-26-2007
    • Posts 9

    Re: What datatype should i use for representing a number with a floating point? (float, double..)

    Hello,

    Setting the decimal delimiter to "." solved the problem so i'm just going to do that every time!

    My software will be run in very different environments / countries and i don't want to risk have something  that only works here! :o/

    Thanks for your help!

    Luís 

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems