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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:58:22+00:00 2026-06-08T06:58:22+00:00

How would the following pseudocode translate into Python? function IntNoise(32-bit integer: x) x =

  • 0

How would the following pseudocode translate into Python?

function IntNoise(32-bit integer: x)             

    x = (x<<13) ^ x;
    return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 7fffffff) / 1073741824.0);    

end IntNoise function  

I’m not sure about the following items: the 32-bit integer: x argument in the IntNoise call ; the <<, and the &7fffffff.

The function is a random number generator from this webpage: Perlin Noise.

  • 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-08T06:58:23+00:00Added an answer on June 8, 2026 at 6:58 am

    Line by line, here are the changes:

    1. function IntNoise(32-bit integer: x)

      We don’t need to declare the argument type, and prefer not to use CamelCase, so line one is:

      def intnoise(x):
      
    2. The only thing wrong with the next line is the semicolon. Removing it, we get:

      x = (x << 13) ^ x
      

      x will be shifted to the left by 13 bits and then the result will be bitwise exclusive-OR-ed with the starting value of x.

    3. On the next line, once again no semicolon, and the 7ffffff needs to be prefixed with 0x, thus:

      return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0)
      

    Altogether, this makes:

    def intnoise(x):
        x = (x << 13) ^ x
        return (1.0 - ((x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code is an example of what I think would qualify as pseudocode,
What would the cleanest way to the following pseudocode be? class Player id name
I would like to define the following function in Objective-C. I have provided pseudo-code
How could I make the following call in Python? Pseudocode version: jsonTwitterResponse = twitter.get(up
Would following the table below be the best way of determining the access type
Why would the following swap action fail at random times? int i,p,a[11] = {0,1,2,3,4,5,6,7,8,9,10
I thought the following would be a pretty common task and assumed there would
I was hoping the following would be parseable in StAX, <something a=b/> <something a=b/>
When using ASP.net webforms my usual solution would have following type of setup -
As the question states, would the following array require 5 bits of memory? $flags

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.