Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 535813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:45:22+00:00 2026-05-13T09:45:22+00:00

Hey, working on some categories and I’ve bumped up against a weird issue, im

  • 0

Hey, working on some categories and I’ve bumped up against a weird issue, im basically expanding on a calculator class to add some trig methods, and i am getting an incorrect value when i call the sin method in the return in the form of a double. i send a value of 100.7 to the method and it returns 0.168231, from what i can see the correct value should be = 0.939693 or there abouts.

heres the code, I’m also attaching a link to the full project here:

(thanks)

http://files.me.com/knyck2/svpfd4

//
//  Calculator_trig.m
//  11.4_calculator_trig
//
//  Created by Nicholas Iannone on 1/6/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "Calculator_trig.h"
#import <math.h>

@implementation Calculator (Trigonometry)

-(double) sin
{
 double result;

 result =   (double) sin (accumulator);

 return result;

}
-(double) cos
{
 double result;

 result =  cos ( accumulator);

 return result;
}
-(double) tan
{
 double result;

 result =  tan ( accumulator);

 return result;
}

@end

    #import "Calculator.h"


@implementation Calculator
-(void) setAccumulator: (double) value
{
 accumulator = value;
}

-(void) clear
{
 accumulator = 0;
}

-(double) accumulator
{
 return accumulator;
}

-(double) memoryClear
{
 memory = 0;
 NSLog(@"memory has been cleared");
 return accumulator;
}

-(double) memoryStore
{
 memory = accumulator;
 NSLog(@"memory has been set to %g", memory);
 return accumulator;
}

-(double) memoryRecall
{
 accumulator = memory;
 NSLog(@"accumulator has been set to %g", accumulator);
 return accumulator;
}

-(double) memoryAdd
{
 memory += accumulator;
 NSLog(@"accumulator: %g has been added to memory, memory is now %g", accumulator, memory);
 return accumulator;
}

-(double) memorySubtract
{
 memory -= accumulator;
 NSLog(@"accumulator: %g has been subtracted from memory, memory is now %g", accumulator, memory);
 return accumulator;
}

-(double) add: (double) value
{
 accumulator += value;
 return accumulator;
}

-(double) subtract: (double) value
{
 accumulator -= value;
 return accumulator;
}

-(double) multiply: (double) value
{
 accumulator *= value;
 return accumulator;
}

-(double) divide: (double) value
{
 accumulator /= value;
 return accumulator;
}

-(double) changeSign
{
 accumulator = -accumulator; 
 return accumulator;
}

-(double) reciprocal
{
 accumulator = 1 / accumulator;
 return accumulator;
}

-(double) xSquared
{
 accumulator *= accumulator;
 return accumulator;
}
@end

    #import <Foundation/Foundation.h>
#import "Calculator.h"
#import "Calculator_trig.h"

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    Calculator *myCalc = [[Calculator alloc] init];

 double a = 0;

 [myCalc setAccumulator: 100.70];
 a = [myCalc sin];

 NSLog(@" sin of accumulator = %f", a);

 [myCalc release];
    [pool drain];
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:45:23+00:00Added an answer on May 13, 2026 at 9:45 am

    You are computing the sin of 100.7 radians, and the answer given is the correct one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, i am currently working on a django app for my studies, and came
Hey everyone, I'm working on a PHP application that needs to parse a .tpl
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd)
Hey right now I'm using jQuery and I have some global variables to hold
Hey so what I want to do is snag the content for the first
Hey, I'm using Levenshteins algorithm to get distance between source and target string. also
Hey all, my Computational Science course this semester is entirely in Java. I was
Hey, I've been developing an application in the windows console with Java, and want
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey peoples, I've been studying Java for a couple of weeks, and have decided

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.