|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
issue of assigning a double variable in .net.I have an issue of displaying a double variable in .net. I receive a double data through socket from C project into .net. The value entering is 2010030550004850. But it gets stored as 2.01003055000485E+15. I need the original value. How can I do this? Can anyone help me out -- Thanks & regards, V.Valli This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email is strictly prohibited and may be unlawful.
Show quote
Hide quote
"Valli" <va***@chellsoft.com> wrote in message The value was stored in "E-notation" in the C program as well, and the value news:esvTvm1yKHA.4492@TK2MSFTNGP05.phx.gbl... > Hi, > > I have an issue of displaying a double variable in .net. > > I receive a double data through socket from C project into .net. The > value entering is 2010030550004850. > But it gets stored as 2.01003055000485E+15. I need the original value. > How can I do this? Can anyone help me out > > -- > Thanks & regards, > > V.Valli > is the same. Typically, you would display the value as a string, using whatever formatting you deem appropriate. How are you attempting to display the value? The .NET Double structure includes a ToString() method designed to help you. http://msdn.microsoft.com/en-us/library/system.double_members.aspx I need to update this value in database in numeric datatype.
The .tostring() methods also returns the value in exponent form only. -- Show quoteHide quoteThanks & regards, V.Valli This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email is strictly prohibited and may be unlawful. "PvdG42" <pvd***@toadstool.edu> wrote in message news:%2363MZx1yKHA.5936@TK2MSFTNGP04.phx.gbl... > > "Valli" <va***@chellsoft.com> wrote in message > news:esvTvm1yKHA.4492@TK2MSFTNGP05.phx.gbl... >> Hi, >> >> I have an issue of displaying a double variable in .net. >> >> I receive a double data through socket from C project into .net. The >> value entering is 2010030550004850. >> But it gets stored as 2.01003055000485E+15. I need the original value. >> How can I do this? Can anyone help me out >> >> -- >> Thanks & regards, >> >> V.Valli >> > The value was stored in "E-notation" in the C program as well, and the > value is the same. Typically, you would display the value as a string, > using whatever formatting you deem appropriate. How are you attempting to > display the value? > The .NET Double structure includes a ToString() method designed to help > you. > > http://msdn.microsoft.com/en-us/library/system.double_members.aspx > > "Valli" wrote: That's true, but if you use the overload value.ToString("f0"), you get the > I need to update this value in database in numeric datatype. > The .tostring() methods also returns the value in exponent form only. > > -- > Thanks & regards, > > V.Valli > > value without the exponentiation. The zero can be replaced with the number of decimal places desired. Mike > I need to update this value in database in numeric datatype. A best practice is to used parameters rather than using a string inside a > The .tostring() methods also returns the value in exponent form only. SQL statement : - you'll be less sensitive to SQL injection attacks - you could have the same problem with the decimal separator and dates and even strings (if the string includes a ' character). See : http://msdn.microsoft.com/en-us/library/yy6y35y8.aspx The key thing to realize is that you almost never see the real value. A date and even a decimal value are allways shown according to a text representation that depends on the country etc... Using parameters takes care of "transporting" the value under a culture insensitive format. Else you have to do this job yourself... -- Patrice They are the same value. It seems you are confusing how the variable is
really stored in memory and its text representation (the default is "G"eneral which is the shortest between fixed point and scientific notation) .. For example here if I display a variable to which I assigned 1.2, I'll see 1,2. But the underlying value is stored the same than on every other computer on earth. It is just that the text representation for my country uses a comma rather than a dot. You can control the format used to display the value using http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx but knowing more about the context could help (for example if you display this in a form, you have form mechanism for formatting). Try the "f" format or perhaps a custom format depending on how you want to handle decimal places... -- Patrice "Valli" <va***@chellsoft.com> a écrit dans le message de groupe de discussion : esvTvm1yKHA.4***@TK2MSFTNGP05.phx.gbl...Show quoteHide quote > Hi, > > I have an issue of displaying a double variable in .net. > > I receive a double data through socket from C project into .net. The > value entering is 2010030550004850. > But it gets stored as 2.01003055000485E+15. I need the original value. > How can I do this? Can anyone help me out > > -- > Thanks & regards, > > V.Valli > > > This e-mail and any files transmitted with it are for the sole use of the > intended recipient(s) and may contain confidential and privileged > information. If you are not the intended recipient, please contact the > sender by reply e-mail and destroy all copies of the original message. > > Any unauthorized review, use, disclosure, dissemination, forwarding, > printing or copying of this email is strictly prohibited and may be > unlawful. > > |
|||||||||||||||||||||||