Unix Technical Forum

Converting real to varchar - but not 'exponent' format

This is a discussion on Converting real to varchar - but not 'exponent' format within the Sybase forums, part of the Database Server Software category; --> create table #t (a real not null, b real not null) go insert into #t (a, b) values (1, ...


Go Back   Unix Technical Forum > Database Server Software > Sybase

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 04:06 PM
Ed Avis
 
Posts: n/a
Default Converting real to varchar - but not 'exponent' format

create table #t (a real not null, b real not null)
go
insert into #t (a, b) values (1, 10000.1)
insert into #t (a, b) values (1, 1000.1)
go
select convert(varchar(255), a / b) from #t
go

This returns the two rows

9.9999000667594373e-05
.00099990004673600197

The trouble is the 'e-05' representation. I would like to convert a
real to a varchar getting just digits and decimal point, in other
words

.000099999000667594373
.00099990004673600197

Is this possible?

--
Ed Avis <ed@membled.com>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 04:06 PM
Carl Kayser
 
Posts: n/a
Default Re: Converting real to varchar - but not 'exponent' format

select substring (convert (char (23), convert (numeric (38, 36), (a / b))),
2, 22)

from #t

go



"Ed Avis" <ed@membled.com> wrote in message
news:l1oev04n82.fsf@budvar.future-i.net...
> create table #t (a real not null, b real not null)
> go
> insert into #t (a, b) values (1, 10000.1)
> insert into #t (a, b) values (1, 1000.1)
> go
> select convert(varchar(255), a / b) from #t
> go
>
> This returns the two rows
>
> 9.9999000667594373e-05
> .00099990004673600197
>
> The trouble is the 'e-05' representation. I would like to convert a
> real to a varchar getting just digits and decimal point, in other
> words
>
> .000099999000667594373
> .00099990004673600197
>
> Is this possible?
>
> --
> Ed Avis <ed@membled.com>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 04:06 PM
Bret Halford
 
Posts: n/a
Default Re: Converting real to varchar - but not 'exponent' format

Ed Avis <ed@membled.com> wrote in message news:<l1oev04n82.fsf@budvar.future-i.net>...
> create table #t (a real not null, b real not null)
> go
> insert into #t (a, b) values (1, 10000.1)
> insert into #t (a, b) values (1, 1000.1)
> go
> select convert(varchar(255), a / b) from #t
> go
>
> This returns the two rows
>
> 9.9999000667594373e-05
> .00099990004673600197
>
> The trouble is the 'e-05' representation. I would like to convert a
> real to a varchar getting just digits and decimal point, in other
> words
>
> .000099999000667594373
> .00099990004673600197
>
> Is this possible?



Use the STR() function, converting FLOAT to string is what it is made for.

-bret
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:34 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com