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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:43:34+00:00 2026-06-06T18:43:34+00:00

I have the code unsigned long long f(unsigned long long x, unsigned long long

  • 0

I have the code

unsigned long long f(unsigned long long x, unsigned long long y){
   return sqrt( ( (5*x*x + 1) * (5*y*y +1) - 1 ) / 4 );         
}

but if x or y is too big, the thing overflows even though the output is supposed to be small. is there a way around this?

  • 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-06-06T18:43:36+00:00Added an answer on June 6, 2026 at 6:43 pm

    Split the argument of the square root up algebraically, maybe?:

    return sqrt((3*x*x+1)/2) * sqrt((6*y*y-5)/2);
    

    Or split it up further based on your needs.

    If x is big enough you can ignore the +1 and make the first term:

    sqrt((3*x*x)/2) = fabs(x) * sqrt(3.0/2.0)
    

    and similarly with y for the second term, making it

    sqrt((6*y*y)/2) = fabs(y) * sqrt(3.0);
    

    EDIT: After OP edited his question to be:

    return sqrt(((3*x*x+1)*(6*y*y-5)-1)/4);  
    

    You can in fact split things up. You just have to be a little bit more careful. Bottom line is that if x is really big, then the +1 can be ignored. If y is really big then the -5 can be ignored. If both (3*x*x+1) and (6*y*y-5) are positive and either is really big, then the -1 can be ignored. You can use these tips and some additional surrounding logic to break this down a bit further. Like this:

     if(fabs(x) > BIGNUMBER && fabs(y) > BIGNUMBER)
     {
         return fabs(x) * fabs(y) * sqrt(18.0/4.0);
     }
     if(fabs(x) > BIGNUMBER && fabs(y) > 1.0)  // x big and y term positive
     {
         return fabs(x) * sqrt(6*y*y-5) * sqrt(3.0/2.0);
     }
     if(fabs(y) > BIGNUMBER)  // x term positive and y big
     {
         return sqrt(3*x*x+1) * fabs(y) * sqrt(6.0/2.0);
     }
     return sqrt(((3*x*x+1)*(6*y*y-5)-1)/4); 
    

    You can optimize this, but this is just meant to show the point.

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

Sidebar

Related Questions

I have the following typedef's in my code: typedef unsigned long int ulint; typedef
I have the code: unsigned int length = strlen(somestring); I'm compiling with the warning
I have the following code int ParseData(unsigned char *packet, int len) { struct ethhdr
I have a code like this below in /root_project/main.cpp : #include theoraplayer/TheoraVideoClip.h unsigned int
Let's say that I have a code like this: NSAutoreleasePool* pool=[[NSAutoreleasePool alloc]init]; for(unsigned int
I have the exercise with following code int FindFirstSet(unsigned BitMap, unsigned start) { unsigned
I have the following code: tmp_data = simulated_data[index_data]; unsigned char *dem_content_buff; dem_content_buff = new
I have code that generates a List<string[]> variable but can't quite figure out how
I'm trying input validation in the following piece of code: typedef unsigned long DATATYPE;
I have a class which has one private member: std::set<unsigned long> Sset; And I

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.