Results 1 to 6 of 6
  1. #1

    Default Help:Math.Cos not accurate enough(C#)


    Need help from the masters again...Hope they see this

    So im doing a bpo project wherein accuracy is important...the problem is when i use the math.cos function it only gives me a double return value...

    in excel it works fine..here is my function in excel

    =0.025*COS(1/180*PI())

    it gives me the correct and precise value of 0.024996192

    but when i do it in c#

    decimal answer= 0.025 * Convert.ToDecimal(Math.Cos(1 / 180 * Math.PI))

    it gives me a round off value of .025.. T.T....mga master pls help me

  2. #2

    Default Re: Help:Math.Cos not accurate enough(C#)

    Try:

    Double answer = 0.025D * Math.Cos(1D / 180 * Math.PI);

    Gamit ug double bai kay mas dako ug range.

  3. #3

    Default Re: Help:Math.Cos not accurate enough(C#)

    mas dako diay ug range and double bai? ang ako man gud is less than 0 ra tanan mao ga gamit kug decimal....hmmm ill try nya your technique master...tnx ^.^

  4. #4

    Default Re: Help:Math.Cos not accurate enough(C#)

    gi-round off man ang result.

    usahay, mga ingon ana style, mag initialize pa ka og lain nga functions/library.

    try daw ni bro,

    String Format for Double [C#]

    wala ko na sweto sa C#. java ko bro. try lang na tun.i..

    EDIT: naa pa d.i bro.. http://www.dotnetperls.com/decimal
    Daghan man example sa internet bro...
    Last edited by stealthghost; 10-25-2011 at 10:22 AM.

  5. #5

    Default Re: Help:Math.Cos not accurate enough(C#)

    Quote Originally Posted by stealthghost View Post
    gi-round off man ang result.

    usahay, mga ingon ana style, mag initialize pa ka og lain nga functions/library.

    try daw ni bro,

    String Format for Double [C#]

    wala ko na sweto sa C#. java ko bro. try lang na tun.i..

    EDIT: naa pa d.i bro.. C# Decimal Examples
    Daghan man example sa internet bro...
    solve na bai tnx to idywts answer...abi nko ang mo round off kay ang Math na class gud....problem with datatypes ra diay

  6. #6

    Default Re: Help:Math.Cos not accurate enough(C#)

    Quote Originally Posted by Deathnote View Post
    mas dako diay ug range and double bai? ang ako man gud is less than 0 ra tanan mao ga gamit kug decimal....hmmm ill try nya your technique master...tnx ^.^

    oo bai. read ug .net datatypes. compare it with others, pila ang precission sa uban. And besides ang Math.Cos() returns and accepts double types. be precise ug gamit sa datatypes labi na expect ka ug gagmay na values.

  7.    Advertisement

Similar Threads

 
  1. HELP on pc not starting up...
    By bilyotoy1 in forum Computer Hardware
    Replies: 12
    Last Post: 11-17-2008, 02:26 AM
  2. HELP "iver irql not less or equal"?
    By macme in forum Computer Hardware
    Replies: 17
    Last Post: 08-20-2008, 12:55 PM
  3. Need Help CPU will not turn on
    By jonz in forum Computer Hardware
    Replies: 26
    Last Post: 11-16-2007, 11:40 AM
  4. Replies: 5
    Last Post: 11-11-2007, 03:44 AM
  5. Replies: 8
    Last Post: 06-17-2007, 10:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top