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 3976650
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:49:47+00:00 2026-05-20T04:49:47+00:00

I am trying to simply have a segment when selected pick a factor and

  • 0

I am trying to simply have a segment when selected pick a factor and use it in a formula. The problem i am having is converting the factor a (float) into a value a (double) and show this on the display. What am I doing wrong here? Seems like an easy fix but I’ve tried a lot of things to no avail.

.h

NSInteger segPicked, var1, var2;

.m

var1 = 1100;
var2 = 2.5;


- (void) pickOne:(id)sender {   // Selector for twosegment controller
if (checkCondition == properCondition) {
    segUnit.text = [twoSegments titleForSegmentAtIndex: [SixSegments selectedSegmentIndex]];
     segPicked    = [twoSegments selectedSegmentIndex];

    float factor = 0;   

if (segPicked  == 0 ) {
    factor = 0.28;
    } else if (segPicked  == 1 ) {
          factor = 0.16; 
      }

    double  value = (factor*(var1/var2));     <--- It crashes here..
    Result.text = [NSString stringWithFormat:@"Segment with  = ", value];

}

}

  • 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-20T04:49:48+00:00Added an answer on May 20, 2026 at 4:49 am

    check that var2 must be != 0

    and:

       Result.text = [NSString stringWithFormat:@"Segment with  = ", value];
    

    should be:

       Result.text = [NSString stringWithFormat:@"Segment with  = %f", value];
    

    EDIT:

    float factor;
    NSInteger var1;
    NSInteger var2;
    
    float var2_test;
    var1 = 1100;
    var2 = 2.5;
    var2_test = 2.5;
    NSLog(@"int var2: %i, float var2_test: %f", var2, var2_test); // var2=2
    
    factor = 0.16;
    double value;
    value = (factor*(var1/var2));  //  Not Crashes to me!
    
    NSLog(@"******: %f", value);
    

    it all works good to me, no crashes, are you sure it crashes at that point?

    just a consideration:

    var2 = 2.5;
    var2 is: 2 (it’s an integer)

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

Sidebar

Related Questions

I have a datagridview with 9 columns. I am simply trying take the value
I'm having some trouble with the Youtube API. Currently I'm simply trying to have
I have this slideshow that I'm trying to simply move up, but I can't
I have a simple jsfiddle where i am trying to change value of each
What i'm trying to do is just simply have the button load an image
I am trying to segment a Korean string into individual syllable. So the input
I'm making a program in C#, and I am trying to simply have a
ASP.NET front-end .aspx page (hiding code when deployed). I'm trying to simply have a
I'm just trying to have simply RndInt(limit) function that will return random numbers with
This is not wanting to work for some reason. I'm simply trying to have

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.