Re: how to assigned float number to DB ?



On Sat, 23 Jun 2007 01:38:00 -0700, guy wrote:

how can i assigned a float number with only one digit after the dot to the DB ?
i mean that i want to write this number 0.1 and not this 0.100000000 (that
what the sql does for me now..)
im using a storage procedure for this purpuse, so maybe the problem is there..

thanks !!

Hi Guy,

The only difference between 0.1 and 0.100000 is representation; their
values are exactyl equal. Since the internal representation for numeric
datatypes is different from what you see anyway, this question really
can't be answered. Whether you assign 0.1, 0.10000 or 0.2/2 to a float
variable or column, the result will always be the same.

So, if you want to STORE numbers with only one decimal place, then
Hari's answer is correct - you can't do that with float numbers, but you
can with the datatype numeric. If, on the other hand, you want to store
float numbers but REPRESENT them with one digit after the decimal place,
check out the subjects STR and CONVERT in Books Online. Note that these
functions convert a float value to a string representation, so the value
is no longer considered a number after this conversion!

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
.



Relevant Pages

  • Re: Double or float - make your mind up!
    ... If the default were float (SQL) ... SQL Server was originally a co-project ... I know I could cast to a float but would there be much point if I'm only doing comparisons, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Float to Decimal Conversion - Transaction Log Fills Up
    ... Col1 float not null, ... SQL Server MVP ... > I am trying to change multiple columns on multiple tables to decimal ... > SQL Server 7 is the version being used. ...
    (microsoft.public.sqlserver.server)
  • Re: Possible bridges between OO programming proponents and relational model
    ... IO representation is a result of loading data pages ... Results of execution traduced as SQL tables are stored according to ... Do you deny that X and Y represent mathematical dimensions? ... the relvar or of the implementation of the relvar. ...
    (comp.databases.theory)
  • Re: Convert float to double - weird failure
    ... bill robertson wrote: ... Float 1.2 is uninterpreted hex 0x3f99999a ... It's converting the float representation of 1.2 which is 0x3f99999a to a double representation which is not even 0x3f99999a00000000. ... unsigned int mantissa:23; ...
    (comp.programming)
  • Re: Replication SQL 2000 -> 2005 Float Error
    ... Director of Text Mining and Database Strategy ... Looking for a SQL Server replication book? ... SQL2000 subscriber. ... The value of this float is 2.8128137561472325E-312. ...
    (microsoft.public.sqlserver.replication)