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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:51:19+00:00 2026-05-25T14:51:19+00:00

Why is it mandatory to use -ffast-math with g++ to achieve the vectorization of

  • 0

Why is it mandatory to use -ffast-math with g++ to achieve the vectorization of loops using doubles? I don’t like -ffast-math because I don’t want to lose precision.

  • 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-25T14:51:20+00:00Added an answer on May 25, 2026 at 2:51 pm

    You don’t necessarily lose precision with -ffast-math. It only affects the handling of NaN, Inf etc. and the order in which operations are performed.

    If you have a specific piece of code where you do not want GCC to reorder or simplify computations, you can mark variables as being used using an asm statement.

    For instance, the following code performs a rounding operation on f. However, the two f += g and f -= g operations are likely to get optimised away by gcc:

    static double moo(double f, double g)                                      
    {                                                                          
        g *= 4503599627370496.0; // 2 ** 52                                    
        f += g;                                                                
        f -= g;                                                                
        return f;                                                            
    }                                                                     
    

    On x86_64, you can use this asm statement to instruct GCC not to perform that optimisation:

    static double moo(double f, double g)                                      
    {                                                                          
        g *= 4503599627370496.0; // 2 ** 52                                    
        f += g;                                                                
        __asm__("" : "+x" (f));
        f -= g;
        return f;
    }
    

    You will need to adapt this for each architecture, unfortunately. On PowerPC, use +f instead of +x.

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

Sidebar

Related Questions

I want to create something like smarty, but I don't want to use Smarty
I need to parse a command line like script.rb <mandatory filename> [options] with optparse
I would like to make an application in a one window using XAML. It
I've looked at Net::Google, and 90% of the modules use AuthSub with a mandatory
I use GLib to parse some command-line options. The problem is that I want
I use syntax like name varchar(20) NOT NULL in mysql..i have a big confusion
Folks, Is it mandatory to use an ALIAS when we are doing some operation
I know I shouldn't use Dev-C++ but it's mandatory in school so I can't
How can i use @Pattern constraint on non-mandatory form fields ? @Pattern(regexp=...) private String
If we use type hinting, we can place an object mandatory: public function myMethodThatDoFineStuff(MyObject

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.