Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 23rd, 2005, 05:59 PM
Authorized User
Points: 82, Level: 1
Points: 82, Level: 1 Points: 82, Level: 1 Points: 82, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Interesting Data Type Problem

The following query returns .038461 as it should:

select (2.0 + 0.0 + 0.0)/52 as x

However, when the numeric literals are replaced by either variables or field names the result is completely different. The query below returns 3.8461538461538464E-2.

declare @a float, @b float, @c float
set @a = 2.0
set @b = 0.0
set @c = 0.0
select (@a + @b + @c)/52

Does anyone know why???????

Thanks,
DL
 
Old February 23rd, 2005, 06:12 PM
Friend of Wrox
 
Join Date: Jan 2004
Location: , , USA.
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default


declare @a float, @b float, @c float
set @a = 2.0
set @b = 0.0
set @c = 0.0
select Round((@a + @b + @c)/52,4)


 
Old February 23rd, 2005, 06:18 PM
Authorized User
Points: 82, Level: 1
Points: 82, Level: 1 Points: 82, Level: 1 Points: 82, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure why that works - but it does. Thanks.

 
Old February 23rd, 2005, 06:23 PM
Friend of Wrox
 
Join Date: Jan 2004
Location: , , USA.
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You got me!
This also works

declare @a real, @b real, @c real
set @a = 2.0
set @b = 0.0
set @c = 0.0
select (@a + @b + @c)/52







Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with variable data-type mlar XSLT 4 June 22nd, 2007 10:39 AM
Interesting Problem prasanta2expert ASP.NET 1.0 and 1.1 Basics 1 October 16th, 2006 08:14 PM
Interesting validation problem jacob ASP.NET 1.0 and 1.1 Professional 5 February 16th, 2006 07:16 PM
Data type mismatch problem dominic_huang Classic ASP Databases 3 November 15th, 2004 03:12 AM
interesting problem - re: database & rollovers highbeef Classic ASP Databases 4 March 2nd, 2004 09:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.