| Author |
Topic |
|
s0ftw4r32002
Starting Member
6 Posts |
Posted - 2008-08-27 : 01:27:29
|
| DECLARE @qty floatDECLARE @value floatSET @qty = 65300000.00SET @value = 26491627.7334113SELECT @value / @qtyresult : 0.40569108320691SELECT 26491627.7334113/65300000.00result = 0.405691083206911Why the result not same?please help me urgent!!! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-27 : 01:30:43
|
because FLOAT is approximate valueYou will get same result if you convert the value in 2nd query to floatSELECT convert(float, 26491627.7334113) / convert(float, 65300000.00) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-27 : 01:34:31
|
quote: Originally posted by s0ftw4r32002 DECLARE @qty floatDECLARE @value floatSET @qty = 65300000.00SET @value = 26491627.7334113SELECT @value / @qtyresult : 0.40569108320691SELECT 26491627.7334113/65300000.00result = 0.405691083206911Why the result not same?please help me urgent!!!
if you want accurate results use Numeric or Decimal where you can specify scale and precision explicitly |
 |
|
|
s0ftw4r32002
Starting Member
6 Posts |
Posted - 2008-08-27 : 01:35:47
|
quote: Originally posted by khtan because FLOAT is approximate valueYou will get same result if you convert the value in 2nd query to floatSELECT convert(float, 26491627.7334113) / convert(float, 65300000.00) KH[spoiler]Time is always against us[/spoiler]
Thank you,I want from the code :DECLARE @qty floatDECLARE @value floatSET @qty = 65300000.00SET @value = 26491627.7334113SELECT @value / @qtythe result : 0.405691083206911 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-27 : 01:38:08
|
use decimal or numeric data type as advice by visakh KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
s0ftw4r32002
Starting Member
6 Posts |
Posted - 2008-08-27 : 01:46:39
|
quote: Originally posted by khtan use decimal or numeric data type as advice by visakh KH[spoiler]Time is always against us[/spoiler]
if i use decimal data type. please tell me about settings scale and precision for result 0.405691083206911 |
 |
|
|
s0ftw4r32002
Starting Member
6 Posts |
Posted - 2008-08-27 : 01:52:23
|
| DECLARE @qty floatDECLARE @value floatDECLARE @cogs floatSET @qty = 65300000.00SET @value = 26491627.7334113 ---> original valueset @cogs = @value / @qtyselect @qty * @cogsresult : 26491627.7334112why the result not back orginal value? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-27 : 02:04:09
|
because FLOAT is approximate value E 12°55'05.25"N 56°04'39.16" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-27 : 02:38:52
|
[code]DECLARE @qty floatDECLARE @value floatSET @qty = 65300000.00SET @value = 26491627.7334113select 0.405691083206911 as [desired], round(@value / @qty, 15) as [calculated][/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|