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 |
|
Aleph_0
Yak Posting Veteran
79 Posts |
Posted - 2011-04-27 : 16:29:34
|
| I saw it in some other code and experimented with it, and I've figured out that 1.0E * an integer keeps it an integer without decimal places (unlike 1.0 * an integer).Can anyone explain what exactly it does? Thanks! |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-04-27 : 16:34:27
|
| 1.0E is actually a float:SELECT SQL_VARIANT_PROPERTY(1.0E,'BaseType')You can try some variations and see how they get cast:SELECT SQL_VARIANT_PROPERTY(1.0,'BaseType')SELECT SQL_VARIANT_PROPERTY(1.,'BaseType')SELECT SQL_VARIANT_PROPERTY(1E,'BaseType') |
 |
|
|
Aleph_0
Yak Posting Veteran
79 Posts |
Posted - 2011-04-27 : 17:17:23
|
| I see. So is there a difference between, say, (1.0E * x) versus CAST(x AS float)? |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-04-27 : 17:20:17
|
| Shouldn't be, but if you mean to CAST something as float, use CAST. Relying on un- or under-documented features is a sure way to drive everyone crazy. Be explicit. |
 |
|
|
Aleph_0
Yak Posting Veteran
79 Posts |
Posted - 2011-04-27 : 17:28:34
|
| Got it. Thanks! |
 |
|
|
|
|
|