Hello -
I am reading up on the NumberFormatInf o class, trying to figure out how to
convert a double to a percentage, using the IFormatProvider . This seems a
little beyond me. Can anyone suggest an easy way to convert a double to a
percentage in C#?
For example, i would like to render on my web page the following:
..89 = 89%
1 = 100%
Thanks, 4 9287
Offhand, I'd guess that multiplying the double by 100 would give you the
percent value.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
"charliewes t" <ch*********@di scussions.micro soft.com> wrote in message
news:14******** *************** ***********@mic rosoft.com... Hello -
I am reading up on the NumberFormatInf o class, trying to figure out how to convert a double to a percentage, using the IFormatProvider . This seems a little beyond me. Can anyone suggest an easy way to convert a double to a percentage in C#?
For example, i would like to render on my web page the following: .89 = 89% 1 = 100%
Thanks,
"charliewes t" <ch*********@di scussions.micro soft.com> wrote in message
news:14******** *************** ***********@mic rosoft.com... For example, i would like to render on my web page the following: .89 = 89% 1 = 100%
double dblTest = 0.89;
string strTest = dblTest.ToStrin g("0%");
1.
Use custom number formatting :
Pass your double to {0:0%}
2.
Format the double with the PercentDecimalD igits property.
Double myInt = 0.1234;
Console.WriteLi ne( myInt.ToString( "P", nfi ) );
will return 12.34 %
See samples at : http://msdn.microsoft.com/library/de...ratortopic.asp
Juan T. Llibre
ASP.NET MVP http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
=============== =======
"charliewes t" <ch*********@di scussions.micro soft.com> wrote in message
news:14******** *************** ***********@mic rosoft.com... Hello -
I am reading up on the NumberFormatInf o class, trying to figure out how to convert a double to a percentage, using the IFormatProvider . This seems a little beyond me. Can anyone suggest an easy way to convert a double to a percentage in C#?
For example, i would like to render on my web page the following: .89 = 89% 1 = 100%
Thanks,
Thanks Kevin,
What i am trying to learn, however, is how to do this using the
NumberFormatInf o class, and/or IFormatProvider interface. This documentation
unfortunately, is not for newbies. Any examples, would be appreciated.
Thanks again,
"Kevin Spencer" wrote: Offhand, I'd guess that multiplying the double by 100 would give you the percent value.
-- HTH,
Kevin Spencer Microsoft MVP ..Net Developer The sun never sets on the Kingdom of Heaven
"charliewes t" <ch*********@di scussions.micro soft.com> wrote in message news:14******** *************** ***********@mic rosoft.com... Hello -
I am reading up on the NumberFormatInf o class, trying to figure out how to convert a double to a percentage, using the IFormatProvider . This seems a little beyond me. Can anyone suggest an easy way to convert a double to a percentage in C#?
For example, i would like to render on my web page the following: .89 = 89% 1 = 100%
Thanks, This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sydex |
last post by:
When I compile code I get error
C2664: 'Integration::qgaus' : cannot convert parameter 1 from 'double
(double)' to 'double (__cdecl *)(double)'
in this part :
double Integration::quad2d(double (*func)(double,double))
{
nfunc = func ;
return qgaus(f1,x1,x2);//error there
|
by: David Scemama |
last post by:
Hi,
I'm writing a program using VB.NET that needs to communicate with a DOS
Pascal program than cannot be modified. The communication channel is through
some file databases, and I have a huge problem writing VB Double values to
the file so as the Pascal program can read them as Pascal Real values.
I've managed to find the algorithm to read the Pascal Real format and
convert it to a VB Double, but I cannot figure out the opposite...
|
by: Eric BOUXIROT |
last post by:
hi,
i must convert all of these eVC++ prototypes to use with VB.NET....
DLLEXPORT long F_BDO_MessageBoxOK(char *IN_title, char *IN_msg );
DLLEXPORT long F_BDO_MessageBoxOUINON(char *IN_title, char *IN_msg );
DLLEXPORT long F_BDO_CalculAXplusB(short int *IN_Tab_entree ,int IN_taille
,
double *OUT_Tab_sortie_freq ,
double *OUT_Tab_sortie, double IN_A,
|
by: PeterK |
last post by:
I am trying to set Public overridable CreditlimitS() as
System.Data.SqlTypes.SqlMoney to Creditlimit as Double
like CreditLimitS=creditlimit
and get this error "Value of type double cannot be converted to
System.Data.SqlTypes.SqlMoney "
How do I get creditlimit into creditlimitS?
There seems to be no conversion function.
TIA
|
by: Mike9900 |
last post by:
I use this code, but I get exception:
String num = "29%";
System.Globalization.NumberFormatInfo ni = new
System.Globalization.NumberFormatInfo(); ni.PercentSymbol = "%";
double nums = double.Parse(num, System.Globalization.NumberStyles.Any, ni);
Is there a way to parse the percent value by using IFormatProvider?
--
Mike
| |
by: VidTheKid |
last post by:
THE PROBLEM
The % symbol is too vague when defining dimensions in CSS and HTML. It
can relate to an inherited value, a measure of the containing element
(which can differ between box models) or for background image
placement, the size of the element minus the size of the image.
A SOLUTION
There should be new %-like units defined in CSS to specify what the
measurement is a percentage of. These take the form of the % sign and
one or...
|
by: Edwin Knoppert |
last post by:
In my code i use the text from a textbox and convert it to a double value.
I was using Convert.ToDouble() but i'm used to convert comma to dot.
This way i can assure the text is correct.
However it seems this convert is determined by the local settings and comma
is indeed used as decimal separator.
Is there another way to convert a dotted value to a double variable?
Like 1234.5 and not 1234,5
|
by: Dilip |
last post by:
Recently in our code, I ran into a situation where were stuffing a
float inside a double. The precision was extended automatically
because of that. To make a long story short, this caused problems
elsewhere in another part of the system where that figure was used for
some calculation and some eventual truncation led to the system going
haywire. So my question is, given this code:
int main()
{
float f = 59.89F;
|
by: gnobbster |
last post by:
Hi everyone,
I was wondering if it was possible to convert a string value containing numeric characters and a '%' character to a double without doing a character-by-character check manually. For example, "89%" to .89 --- any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |