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

  • Home
  • SEARCH
  • 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 3305148
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:08:13+00:00 2026-05-17T21:08:13+00:00

I was checking out an online game physics library today and came across the

  • 0

I was checking out an online game physics library today and came across the ~~ operator. I know a single ~ is a bitwise NOT, would that make ~~ a NOT of a NOT, which would give back the same value, wouldn’t it?

  • 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-17T21:08:13+00:00Added an answer on May 17, 2026 at 9:08 pm

    It removes everything after the decimal point because the bitwise operators implicitly convert their operands to signed 32-bit integers. This works whether the operands are (floating-point) numbers or strings, and the result is a number.

    In other words, it yields:

    function(x) {
      if(x < 0) return Math.ceil(x);
      else return Math.floor(x);
    }
    

    only if x is between -(231) and 231 – 1. Otherwise, overflow will occur and the number will “wrap around”.

    This may be considered useful to convert a function’s string argument to a number, but both because of the possibility of overflow and that it is incorrect for use with non-integers, I would not use it that way except for “code golf” (i.e. pointlessly trimming bytes off the source code of your program at the expense of readability and robustness). I would use +x or Number(x) instead.


    How this is the NOT of the NOT

    The number -43.2, for example is:

    -43.210 = 111111111111111111111111110101012

    as a signed (two’s complement) 32-bit binary number. (JavaScript ignores what is after the decimal point.) Inverting the bits gives:

    NOT -4310 = 000000000000000000000000001010102 = 4210

    Inverting again gives:

    NOT 4210 = 111111111111111111111111110101012 = -4310

    This differs from Math.floor(-43.2) in that negative numbers are rounded toward zero, not away from it. (The floor function, which would equal -44, always rounds down to the next lower integer, regardless of whether the number is positive or negative.)

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

Sidebar

Related Questions

I was checking out imageoptim today, and really would love to run this from
I'm checking out some PHP 5.3.0 features and ran across some code on the
I've been checking out WCF Data Services today and it looks great - but
I know how to checking if internet is available or not in the activity,
On checking out a very large svn repository I would like to throttle the
After checking out code for the first time from a repository into Eclipse using
After checking out a branch in a repository git always prints a list of
I was checking out the TIBCO GI the other day and I was impressed.
I am checking out the code in the reflector, but I haven't yet found
I have been checking out some of the possible timers lately, and System.Threading.Timer and

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.