Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Thu, 17 Jul 2008 13:42:11 -0700,    group: microsoft.public.dotnet.languages.csharp        back       


Number of digits in exponent with "g" format?   
Hello,

By default, the "g" format specifier seems to use 2 digits in the exponent 
if it decides to use the scientific format.  I.e., Double.ToString("g").  How 
do I control the number of exponent digits used without affecting the 
operation of "g" in any other way?  I need it to use 3 digits instead.

Thanks,
Ray
date: Thu, 17 Jul 2008 13:42:11 -0700   author:   Ray Mitchell

Re: Number of digits in exponent with "g" format?   
Ray Mitchell wrote:
> By default, the "g" format specifier seems to use 2 digits in the exponent 
> if it decides to use the scientific format.  I.e., Double.ToString("g").  How 
> do I control the number of exponent digits used without affecting the 
> operation of "g" in any other way?  I need it to use 3 digits instead.

Something like x.ToString("e") or x.ToString("0.00000000e+000") will
always use scientific format with 3 digits in the exponent.

Arne
date: Thu, 17 Jul 2008 20:57:38 -0400   author:   Arne Vajhøj

Re: Number of digits in exponent with "g" format?   
"Arne Vajhøj" wrote:

> Ray Mitchell wrote:
> > By default, the "g" format specifier seems to use 2 digits in the exponent 
> > if it decides to use the scientific format.  I.e., Double.ToString("g").  How 
> > do I control the number of exponent digits used without affecting the 
> > operation of "g" in any other way?  I need it to use 3 digits instead.
> 
> Something like x.ToString("e") or x.ToString("0.00000000e+000") will
> always use scientific format with 3 digits in the exponent.
> 
> Arne
> 

Yes, but I don't always want scientific.  I want it to be done like "g" does 
it except that when it does "choose" scientific, it uses 3 digits of exponent 
instead of 2.
date: Fri, 18 Jul 2008 00:19:00 -0700   author:   Ray Mitchell

Re: Number of digits in exponent with "g" format?   
Ray Mitchell wrote:
> "Arne Vajhøj" wrote:
>> Ray Mitchell wrote:
>>> By default, the "g" format specifier seems to use 2 digits in the exponent 
>>> if it decides to use the scientific format.  I.e., Double.ToString("g").  How 
>>> do I control the number of exponent digits used without affecting the 
>>> operation of "g" in any other way?  I need it to use 3 digits instead.
>> Something like x.ToString("e") or x.ToString("0.00000000e+000") will
>> always use scientific format with 3 digits in the exponent.
> 
> Yes, but I don't always want scientific.  I want it to be done like "g" does 
> it except that when it does "choose" scientific, it uses 3 digits of exponent 
> instead of 2.

Unfortunately there does not seem to be support for that in
.NET (NumberFormatInfo).

You will have to find the borders and write some code
that tests for inside/outside and call code accordingly.

Arne
date: Fri, 18 Jul 2008 21:44:50 -0400   author:   Arne Vajhøj

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us