Re: select on set yields exponential notation

2004-02-07 Thread Michael Stassen
Ah, I see.  Of course.  And adding 0 is exactly what the manual says to do.

I was about to reply to say that |0 works where +0 does not when Bernard 
sent his excellent suggestion to cast as unsigned.  Then I spent a while 
trying to figure out why you got such a large number for '40'.  I 
finally noticed you had '30' twice, '40' where one would expect '50', 
and no '50' in the set definition, so '40' is the 49th element of the 
set.  I don't expect that's a problem for you, as I imagine you just 
made up that table to illustrate the issue, but it boggled my mind for a 
bit.

Now, it seems to me, the question is whether this is a bug or a 
documentation error.

Michael

Greg Vines wrote:

With sets if you select the set, you get a comma delimited list, but if
you add zero, you get the number value of the entire set (which is what
I want).  The response is not always in exponential notation - just when
a high order bit is set.  

This seems to be a problem with the output formatting.  Do you know if
there is a way to set the number of characters in a numeric response?  

On Fri, 2004-02-06 at 12:54, Michael Stassen wrote:

Why are you adding 0?  Try this:

  SELECT var1, var2 FROM test1;

Michael

Greg Vines wrote:


I'm trying to select all the fields from a set but when the number is
large, it is returned in exponential notation.  Is there a way to keep
the returned number an integer?
Example:
create simple table:
create table test1(
 var1 int,
 var2 set(1,2,3,4,5,6,7,8,9,10, 
11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,30,
41,42,43,44,45,46,47,48,49,40,
51,52,53,54,55,56,57,58,59,60)
 );

Add a row:

insert into test1 values (1, 40);

Then select  oops:

select var1,var2+0 from test1;

+--+-+
| var1 | var2+0  |
+--+-+
|1 | 5.6294995342131e+14 |
+--+-+
How can I get this output as an integer?

I've tried both MySQL 3.23 and 4.0.17 with the same result.  I'm running
on linux (RHL 8.0)
Thanks
- Greg




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: select on set yields exponential notation

2004-02-06 Thread Michael Stassen
Why are you adding 0?  Try this:

  SELECT var1, var2 FROM test1;

Michael

Greg Vines wrote:

I'm trying to select all the fields from a set but when the number is
large, it is returned in exponential notation.  Is there a way to keep
the returned number an integer?
Example:
create simple table:
create table test1(
  var1 int,
  var2 set(1,2,3,4,5,6,7,8,9,10, 
 11,12,13,14,15,16,17,18,19,20,
 21,22,23,24,25,26,27,28,29,30,
 31,32,33,34,35,36,37,38,39,30,
 41,42,43,44,45,46,47,48,49,40,
 51,52,53,54,55,56,57,58,59,60)
  );

Add a row:

insert into test1 values (1, 40);

Then select  oops:

select var1,var2+0 from test1;

+--+-+
| var1 | var2+0  |
+--+-+
|1 | 5.6294995342131e+14 |
+--+-+
How can I get this output as an integer?

I've tried both MySQL 3.23 and 4.0.17 with the same result.  I'm running
on linux (RHL 8.0)
Thanks
- Greg




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: select on set yields exponential notation

2004-02-06 Thread Greg Vines
With sets if you select the set, you get a comma delimited list, but if
you add zero, you get the number value of the entire set (which is what
I want).  The response is not always in exponential notation - just when
a high order bit is set.  

This seems to be a problem with the output formatting.  Do you know if
there is a way to set the number of characters in a numeric response?  

On Fri, 2004-02-06 at 12:54, Michael Stassen wrote:
 Why are you adding 0?  Try this:
 
SELECT var1, var2 FROM test1;
 
 Michael
 
 Greg Vines wrote:
 
  I'm trying to select all the fields from a set but when the number is
  large, it is returned in exponential notation.  Is there a way to keep
  the returned number an integer?
  
  Example:
  create simple table:
  
  create table test1(
var1 int,
var2 set(1,2,3,4,5,6,7,8,9,10, 
   11,12,13,14,15,16,17,18,19,20,
   21,22,23,24,25,26,27,28,29,30,
   31,32,33,34,35,36,37,38,39,30,
   41,42,43,44,45,46,47,48,49,40,
   51,52,53,54,55,56,57,58,59,60)
);
  
  Add a row:
  
  insert into test1 values (1, 40);
  
  Then select  oops:
  
  select var1,var2+0 from test1;
  
  +--+-+
  | var1 | var2+0  |
  +--+-+
  |1 | 5.6294995342131e+14 |
  +--+-+
  
  
  How can I get this output as an integer?
  
  I've tried both MySQL 3.23 and 4.0.17 with the same result.  I'm running
  on linux (RHL 8.0)
  
  Thanks
  - Greg
  
  
  
-- 
Greg Vines  mailto:[EMAIL PROTECTED]
Manzanita Systems   http://www.manzanitasystems.com
14400 Midland Road  Voice: (858) 679-8990 x104
Poway, CA 92064 Fax:   (858) 679-8991


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: select on set yields exponential notation

2004-02-06 Thread Bernard Clement

If you are using 4.0.2 and above you can use cast.

mysql select var1,cast(var2 as unsigned) from test1;
+--++
| var1 | cast(var2 as unsigned) |
+--++
|1 |562949953421312 |
|1 |  1 |
|1 |  32768 |
+--++
3 rows in set (0.00 sec)

Note I add a row with 1 and another with 16.

Bernard

On Friday 06 February 2004 16:22, Greg Vines wrote:
 With sets if you select the set, you get a comma delimited list, but if
 you add zero, you get the number value of the entire set (which is what
 I want).  The response is not always in exponential notation - just when
 a high order bit is set.

 This seems to be a problem with the output formatting.  Do you know if
 there is a way to set the number of characters in a numeric response?

 On Fri, 2004-02-06 at 12:54, Michael Stassen wrote:
  Why are you adding 0?  Try this:
 
 SELECT var1, var2 FROM test1;
 
  Michael
 
  Greg Vines wrote:
   I'm trying to select all the fields from a set but when the number is
   large, it is returned in exponential notation.  Is there a way to keep
   the returned number an integer?
  
   Example:
   create simple table:
  
   create table test1(
 var1 int,
 var2 set(1,2,3,4,5,6,7,8,9,10,
11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,30,
41,42,43,44,45,46,47,48,49,40,
51,52,53,54,55,56,57,58,59,60)
 );
  
   Add a row:
  
   insert into test1 values (1, 40);
  
   Then select  oops:
  
   select var1,var2+0 from test1;
  
   +--+-+
  
   | var1 | var2+0  |
  
   +--+-+
  
   |1 | 5.6294995342131e+14 |
  
   +--+-+
  
  
   How can I get this output as an integer?
  
   I've tried both MySQL 3.23 and 4.0.17 with the same result.  I'm
   running on linux (RHL 8.0)
  
   Thanks
   - Greg

 --
 Greg Vines  mailto:[EMAIL PROTECTED]
 Manzanita Systems   http://www.manzanitasystems.com
 14400 Midland Road  Voice: (858) 679-8990 x104
 Poway, CA 92064 Fax:   (858) 679-8991


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: select on set yields exponential notation

2004-02-06 Thread Greg Vines
Thanks Bernard - that fixed it!

On Fri, 2004-02-06 at 13:41, Bernard Clement wrote:
 
 If you are using 4.0.2 and above you can use cast.
 
 mysql select var1,cast(var2 as unsigned) from test1;
 +--++
 | var1 | cast(var2 as unsigned) |
 +--++
 |1 |562949953421312 |
 |1 |  1 |
 |1 |  32768 |
 +--++
 3 rows in set (0.00 sec)
 
 Note I add a row with 1 and another with 16.
 
 Bernard
 
 On Friday 06 February 2004 16:22, Greg Vines wrote:
  With sets if you select the set, you get a comma delimited list, but if
  you add zero, you get the number value of the entire set (which is what
  I want).  The response is not always in exponential notation - just when
  a high order bit is set.
 
  This seems to be a problem with the output formatting.  Do you know if
  there is a way to set the number of characters in a numeric response?
 
  On Fri, 2004-02-06 at 12:54, Michael Stassen wrote:
   Why are you adding 0?  Try this:
  
  SELECT var1, var2 FROM test1;
  
   Michael
  
   Greg Vines wrote:
I'm trying to select all the fields from a set but when the number is
large, it is returned in exponential notation.  Is there a way to keep
the returned number an integer?
   
Example:
create simple table:
   
create table test1(
  var1 int,
  var2 set(1,2,3,4,5,6,7,8,9,10,
 11,12,13,14,15,16,17,18,19,20,
 21,22,23,24,25,26,27,28,29,30,
 31,32,33,34,35,36,37,38,39,30,
 41,42,43,44,45,46,47,48,49,40,
 51,52,53,54,55,56,57,58,59,60)
  );
   
Add a row:
   
insert into test1 values (1, 40);
   
Then select  oops:
   
select var1,var2+0 from test1;
   
+--+-+
   
| var1 | var2+0  |
   
+--+-+
   
|1 | 5.6294995342131e+14 |
   
+--+-+
   
   
How can I get this output as an integer?
   
I've tried both MySQL 3.23 and 4.0.17 with the same result.  I'm
running on linux (RHL 8.0)
   
Thanks
- Greg
 
  --
  Greg Vines  mailto:[EMAIL PROTECTED]
  Manzanita Systems   http://www.manzanitasystems.com
  14400 Midland Road  Voice: (858) 679-8990 x104
  Poway, CA 92064 Fax:   (858) 679-8991
-- 
Greg Vines  mailto:[EMAIL PROTECTED]
Manzanita Systems   http://www.manzanitasystems.com
14400 Midland Road  Voice: (858) 679-8990 x104
Poway, CA 92064 Fax:   (858) 679-8991


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]