Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Float to String Conversion

Status
Not open for further replies.

kav123

Programmer
Jan 12, 2005
210
GB
I am passing a value stored as Real datatype in database(SQL 2005), and passing it onto an external payment site. Now before passing this, i am converting it to a string datatype and replacing the "." by "", because all the information to be sent is combined in a string. However, when it reaches that site, the value displayed is 3 decimal places forward, so say the value which i am passing is 17.236, the new value would be 17236....

However, what's puzzling me is that there is also another value which is stored as float in the database, when that is passed, in a similar fashion is showing the information correctly, i.e. at the correct precision point. Not sure what's going on... could this be a culture issue??
 
If it is being displayed incorrectly once you pass it, then it is the other party's issue to correct. The only way it would be a culture issue, is if you are passing values to another app that is on another server.
 
Actually it is another application hosted on another server. But what puzzles me, is that a similar formatting done to a float datatype(as stored in database) is working fine.

Does .Net treat formatting of real and float datatypes differently. I was thinking of converting real datatype to float and then convert that to a string
 
It doesn't matter what you do on your end if you are sending a string. Coverting to one datatype instead of another and then to a string won't make a difference. It is something on the other end.
 
Cool, ok but if the same thing is working fine for float, but not for another variable is what puzzles me... ok i will see what they say about it.
 
You are not passing a float or decimal or any other numeric type. You are passing a string, so it doesn't matter what it's original datatype was, it is now a string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top