|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
single to string problemHi,
can someone help me with that, it's driving me nuts... ----- dim s as single = 42.5 dim msg as string = s.tostring() ' now msg is supposed to hold 42.5 but NO it's rather containing 43 ----- It seems the tostring() function rounds the number but I don't understand why it does... thanks, ibiza ibiza,
Bizarre. I copy/pasted your code into a new console app (vb.net 2003) and it worked fine. Have you tried overloading the ToString( ) with a specific format string? Trying using s.tostring("r") and see if the output is the same. wow...with the "r" format string it seems to work ok
thank you so much! Anyways, I wonder why this time the functions rounds the single...it usually does NOT O_o and what's the "r" for? THANKS again! :) ibiza ibiza,
By default, ToString should return 7 digits of precision but it sounds like it isn't doing that in your code. Passing it "r" or "R" in the ToString method does this..."returns 7 digits if the number can be represented with that precision or 9 digits if the number can only be represented with maximum precision." - from the MSDN information on Single.
Read Emails on Exchange server without OL client
VB2005 timing/speed problem File Names: List Long file Names from Database List of short file names help logging events to txt file set focus from treeview to control Error setting CSV to display text Invalid format of DLL How do I take a screenshot in VB.net 2005 IDE hangs pinning toolbox so it's open Get control's absolute/screen left/top? |
|||||||||||||||||||||||