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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:58:39+00:00 2026-05-24T18:58:39+00:00

Having trouble comparing 4 float values in objective c, I would like to return

  • 0

Having trouble comparing 4 float values in objective c, I would like to return the highest or equal values of these 4 integers. As you can see two are the same here.

This is the NSLOG output

2011-08-17 17:17:30.328 [21087:c203] 1 = 6.000000
2011-08-17 17:17:30.328 [21087:c203] 2 = 4.400000
2011-08-17 17:17:30.352 [21087:c203] 3 = 0.000000
2011-08-17 17:17:30.353 [21087:c203] 4 = 6.000000

Lets say 1-4

I have tried the MAX(1,2) Statement
Also checked >= value using if and statements too..

I am able to write my own code for comparing the values using an algorythm but I wanted to check to see if there is an easier way to do it and save me some headache??

Perhaps creating a float with a really high value and then comparing which one was the closest to it??

I have tried reading this site and its just confusing me

I am kind of new to objective c, have done it for 2 years but still sometimes it stumps you!!

Edit – Solved by brain!..

2011-08-18 12:10:26.798 iT[2093:c203] 1 = 6.710000 
2011-08-18 12:10:26.798 iT[2093:c203] 2 = 0.000000 
2011-08-18 12:10:26.799 iT[2093:c203] 3 = 7.000000 
2011-08-18 12:10:26.800 iT[2093:c203] 4 is 9.000000 

float max = MAX(1,MAX(2,MAX(3,4))); NSLog(@"Max is %f", max); 

NSLog Output "Max is 9.000000"

Such an easy way to solve it, Brilliant!

  • 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-24T18:58:40+00:00Added an answer on May 24, 2026 at 6:58 pm

    Seems pretty simple to me to just nest the max calls:

    max(1,max(2,max(3,4)))
    

    Where 1,2,3,4 refer to the variable names.

    Usually this sort of thing is done over collections, in which case you can so something like this (in pseudocode):

    float max = Float.Min_Value;
    for (float f in float_array) {
        if (f > max) {
            max = f;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble comparing values found in VARCHAR fields. I have a table
I am having trouble comparing these two strings, I am not exactly sure what
I don't know much about multimedia development and am having some trouble comparing Silverlight
I'm having trouble with a templated comparison operator for comparing instances of a type
I'm having trouble comparing strings in C (with which I am fairly new to).
Having trouble with the examples for the .RowStart method. Comparing the 2 syntaxes: http://www.jeremyskinner.co.uk/2009/03/01/mvccontrib-grid-part-5-the-action-syntax/
I'm having trouble composing a CakePHP find() which returns the records I'm looking for.
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
Having trouble with the following segment of code. I'm getting a parameter count mismatch.

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.