dbTalk Databases Forums  

Converting real to varchar - but not 'exponent' format

comp.databases.sybase comp.databases.sybase


Discuss Converting real to varchar - but not 'exponent' format in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ed Avis
 
Posts: n/a

Default Converting real to varchar - but not 'exponent' format - 11-25-2003 , 07:00 AM






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 (AT) membled (DOT) com>


Reply With Quote
  #2  
Old   
Carl Kayser
 
Posts: n/a

Default Re: Converting real to varchar - but not 'exponent' format - 11-25-2003 , 07:31 AM






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

from #t

go



"Ed Avis" <ed (AT) membled (DOT) com> wrote

Quote:
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 (AT) membled (DOT) com




Reply With Quote
  #3  
Old   
Bret Halford
 
Posts: n/a

Default Re: Converting real to varchar - but not 'exponent' format - 11-25-2003 , 03:05 PM



Ed Avis <ed (AT) membled (DOT) com> wrote

Quote:
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


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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.