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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:31:33+00:00 2026-05-27T04:31:33+00:00

im totally new at stack overflow, I usually just research stuff myself but I

  • 0

im totally new at stack overflow, I usually just research stuff myself but I just started using xcode 4.2 and I cant help finding it weird.

These are the issues:

why cant i multiply by (1/2) but i can by 0.5? If i try the first option it will think its 0.

and second, is this if statement wrong?

if (-1 < x < 0)

I could swear i have done that in other programming languages but it wont work here, so i had to change to if ((-1 < x) && (x < 0))

Thank you for your time.

  • 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-27T04:31:34+00:00Added an answer on May 27, 2026 at 4:31 am

    This is nothing to do with Xcode, it’s to do with the C language.

    The first issue:

    x * (1 / 2)
    

    The C compiler treats 1 and 2 as ints, and in integer math, 1 / 2 = 0. If you want to multiply as floats, you can do:

    x * (1.0 / 2.0)
    

    or

    x * ((float) 1 / (float) 2)
    

    In your second issue, the compiler will interpret (-1 < x < 0) as ((-1 < x) < 0), which is obviously not what you want, since (-1 < x) will return either 0 for false, or 1 for true. To do compound logic statements in C, you need to use && for AND or || for OR:

    ((-1 < x) && (x < 0))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm totally new to django, and I'm using its documentation to get help on
I've recently started work on a new project using EpiServer which I am totally
I'm totally new to both java and java Server worlds... But I've a good
I'm totally new to GreaseMonkey, but I'm trying to make a little script. //
I'm totally new to the ASP.NET MVC stack, and I was wondering what happened
I'm totally new to XCode 3 (running Snow Leopard) and have no idea what
My question is straight forward. I'm totally new to the Microsoft stack, I have
I am totally new to SQL . I have a simple select query similar
I am totally new to XSLT and can't work out where I am going
I am absolutely and totally new to rails, so the answer is probably very

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.