473,466 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Math.Ceiling, how to cast the value, proper synthax?

7 New Member
Hi Im trying to Math.Ceiling with the following code, where fr is a array of doubles and max is an int, it give me the following error "Error The call is ambiguous between the following methods or properties: 'System.Math.Ceiling(decimal)' and 'System.Math.Ceiling(double)'"

Expand|Select|Wrap|Line Numbers
  1. for (int i = 0; i < fr.Length; i++)
  2.             {
  3.                 if (fr[i] < max)
  4.                 {
  5.                     max = (int)Math.Ceiling(i);
  6.                 }
  7.             }
  8.  
Please advise Thanks
Sep 18 '10 #1
1 3879
Anton Zinchenko
16 New Member
Maybe you made a typo?
Expand|Select|Wrap|Line Numbers
  1.             for (int i = 0; i < fr.Length; i++)
  2.             {
  3.                 if (fr[i] < max)
  4.                 {
  5.                     max = (int)Math.Ceiling(fr[i]);
  6.                 }
  7.             }
If it's not a typo, than you can cast i to double and it should work (max = (int)Math.Ceiling((double)i);)
Sep 20 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Nicole Szymanski | last post by:
Hello, I am developing a XML application that uses XSLT in order to transform math lessons written in XML to XHTML. I write TEX equation between math tags, for instance : ...
8
by: Tom | last post by:
Has anyone ever seen a IComparer for floats the returns magnitude. i.e. instead of returning -1, it would return -5. To let you know HOW different the two numbers are. obviously for int it is a -...
0
by: Aaron W. West | last post by:
Fun with CAST! (Optimized SQLServerCentral script posts) I found some interesting "tricks" to convert binary to hexadecimal and back, which allow doing 4 or 8 at a time. Test code first: --...
5
by: RichW | last post by:
Hi, I'm writing a program that has got a bit of maths in it. I perform a division and then end up with something like 2.50, or 3.87, or 4.9975 (ie. y.12345). I need to get rid of anything in...
12
by: Test User | last post by:
Hi all, I have learnt that if I want to round 0.5 to an integer the result should be 1, This is also the case if I do it in SQL server 2000, but if I do it in VB.NET the result will be 0. ...
3
by: Agnes | last post by:
my number is 100.1 , Now I only want to get 100 without any round up or round down function, Can anyone told me which function can do that ? Thanks
4
by: Ryan Liu | last post by:
Is there a good reason that Decimal does not have Ceiling() method, only Math class has? Thanks!
6
by: Jon Vaughan | last post by:
Can someone tell me why the following statement gives me the result of 0 : Math.Ceiling( 1 / 12); Well actually the above is simplefied from : private const int LocationsPerPage = 12; ...
10
by: David Coleman | last post by:
I am running VS 2003 and have applied SP1. (On WinXP SP2, .Net 1.1) In the Command Window I get the following ? Math.Round(0.715, 2) 0.72 ? Math.Round(0.725, 2) 0.72 ? Math.Round(0.735, 2)...
5
by: matthias s | last post by:
Hi there, I believed that Math.Ceiling is like Math.Round except that it always rounds up to the next but this double d = Math.Ceiling(29/15);
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.