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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:17:54+00:00 2026-05-29T23:17:54+00:00

If I write a line of code for a math operation, such as: x

  • 0

If I write a line of code for a math operation, such as:

x = 109.0f*768.0f/320.0f;

Is the result (261.6f) computed at compile time or run time? In other words, does Xcode’s optimization recognize that the result of a hard-coded math operation will always be the same, and thus can be pre-computed while compiling?

  • 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-29T23:17:56+00:00Added an answer on May 29, 2026 at 11:17 pm

    It is computed at compile time, at least using Xcode targetting iOS. This function:

    float test() {
        float x = 109.0f*768.0f/320.0f;
        return x;
    }
    

    compiles to these three instructions:

    movw    r0, #52429
    movt    r0, #17282
    bx  lr
    

    Computing the value at compile-time isn’t required by the C standard. In fact, if you set the FENV_ACCESS pragma, there are cases where it’s forbidden from computing it at compile-time. Turning on FENV_ACCESS didn’t affect the generated instructions in this test case.

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

Sidebar

Related Questions

I've just tried to write line code to visualize a simple math; Here it
In code, if I write a code line like this: GClass<Double> x = new
I came across a javascript puzzle asking: Write a one-line piece of JavaScript code
I am trying to write some code that that will draw the line which
Why does the following code: Console.WriteLine(String.Format({0:C0}, 2170/ 20)); yield $109, while doing Console.WriteLine(Math.Round(2170 /
I'm just starting to learn Xpath, I'm trying to write a line of code
The code: #include stdafx.h #include stdio.h #include math.h #include stdlib.h #include time.h int main()
Since I write a command line program to check cpp files, and it need
I am attempting to write a one-line Perl script that will toggle a line
I want to write a command line program to add a contact to GoogleMail.

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.