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

  • Home
  • SEARCH
  • 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 8923699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:12:18+00:00 2026-06-15T07:12:18+00:00

To get a square root value of mainlabelString , I am using – (IBAction)rootPressed:(id)sender

  • 0

To get a square root value of mainlabelString, I am using

- (IBAction)rootPressed:(id)sender
{

    NSString *mainLabelString = mainLabel.text;

    int mainLabelValue = [mainLabelString longLongValue];

    NSString *calculatedValue = [NSString stringWithFormat: @"%f", sqrt(mainLabelValue)];

    mainLabel.text = calculatedValue;

}

And although it does work with numbers such as 88, from which I get 9.380832, it does not for example work with that number, for which it says the square root is 3.000000 (instead of 3.062814).
I tried replacing longLongValue with doubleValue and integerValue but it doesn’t change it.
What’s wrong?

  • 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-06-15T07:12:19+00:00Added an answer on June 15, 2026 at 7:12 am

    If the value into the text field is like @”9.0001″, getting the long long value truncates the decimal part.You said that you also have tried doubleValue, but I suspect that you did something like this:

    int mainLabelValue = [mainLabelString doubleValue]; 
    

    Instead of:

    double mainLabelValue = [mainLabelString doubleValue]; 
    

    In the first case the number loses the decimal part too, because an int can’t store the decimal part, nor a long long int.
    Let me know how you exactly tried to retrieve the double value of the text field.

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

Sidebar

Related Questions

How do you get a square root and an absolute value in Java? Here
I need to get the square root of a 210 digit number accurately, I
How can i get 64 bits of the fractional part of the square root
I'm trying to get it so that if I move a red div-square around
In T-SQL, you can use square brackets to get around the fact that some
I want to get the absolute value of a number in JavaScript. That is,
I'm trying to get an array of (9) numbers square rooted then printed but
I'm working to finish a math problem that approximates the square root of a
I need to get the power value of a given number by user (as
How do you write your own function for finding the most accurate square root

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.