Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 22nd, 2004, 08:30 PM
Registered User
Join Date: Dec 2004
Location: Irving, Texas, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default C# - Decimal to Single type Conversions

When I convert Single type to Double type I want the number of zeroes to be maintained as same. For example my case is as follows

I send a request say "request1" to our clients web service "method1", the response say "response1" that I get back contains a field called "Value" that stores price value and it is of single datatype.

In my project I am storing all Price Values as Decimal DataTypes hence I convert the value of "Value" to Decimal, below is the sample code

a) oAvailRoom.oRate.cRate = Convert.ToDecimal(oRate.Price.Value.ToString());

In the above sample cRate is of decimal type and Value of Single type.

Now, I form another request say request2 using "response1" and convert Decimal to Single type as follows

b) oPriceCheck.Price.Value = Decimal.ToSingle(this.oAvailRoom.oRate.cRate);

Note: here "this.oAvailRoom.oRate.cRate = 221.2"

when I pass this request to Method2 of my clients webservice all the values needs to be same as what I have got in the previous request, if say in the previous response I get Value as "221.20" in the method2 I need to pass the same value I CANNOT PASS "221.2".

But in (a) when I convert it to decimal its becoming "221.2" which is right, but is there a way that I can maintain it as "221.20". Because in (b) I need to pass it as "221.20".
Reply With Quote
  #2 (permalink)  
Old December 22nd, 2004, 08:48 PM
Friend of Wrox
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts

Please post in the C# forum, this is actually the feedback area.

-Snib - http://www.snibworks.com
Where will you be in 100 years?
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL conversions - chapter 7 gorillapoop BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 2 February 15th, 2011 11:02 AM
Sql error for decimal type input parameter suru_07 ADO.NET 0 November 27th, 2007 12:45 AM
decimal data type all 0's after decimal gobotsoup SQL Server ASP 1 February 28th, 2007 02:32 PM
Type Conversions nikotromus Access VBA 2 October 7th, 2004 05:30 PM

All times are GMT -4. The time now is 01:56 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.