Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 22nd, 2004, 08:30 PM
Registered User
 
Join Date: Dec 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default C# - Decimal to Single type Conversions

Hi,
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".
 
Old December 22nd, 2004, 08:48 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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

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





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





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