Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
helpme
Posting Yak Master
141 Posts |
Posted - 2005-02-12 : 15:23:57
|
| If I have a variable named fld-a that contains the value206.249999999999, is there a way to check the positionspast 206.24 to see if they are equal to '9999999999'. fld-a is a computed value (basically sums of percentages that in some cases go off into infinity) and I won't know what the result is(ie. it could be 58.219999999999, 1442.689999999999, 44.23, etc.),but I want to be able to test it to see if these trailingpositions (3rd decimal position on) are 9's.Thanks in advance. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-02-12 : 15:38:39
|
| Sounds like a float which is an approximate data type so "equal to" isn't a term you should be using.consider convert(float,2.1) = 2.1000000000000001you can do compares by converting to decimal e.g.select 'yes' where convert(decimal(30,12),convert(float,206.249999999999)) = 206.249999999999==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-02-12 : 15:45:02
|
another way:declare @b varchar(20)set @b = '206.249999999999'declare @lastDigits intset @lastDigits = 8select @b , case when right(@b, @lastDigits) = replicate('9', @lastDigits) then 1 else 0 endGo with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|