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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:17:33+00:00 2026-05-27T11:17:33+00:00

i tried to write this function: http://uggedal.com/reddit.cf.algorithm.png in javascript: function getRating(t,u,d){ var x =

  • 0

i tried to write this function: http://uggedal.com/reddit.cf.algorithm.png in javascript:

function getRating(t,u,d){

        var x = u-d;

        if(x > 0)
            y = 1
        else if(x == 0)
            y = 0
        else if(x < 0)
            y = -1

        var z = Math.max(1,Math.abs(x));

        return Math.log(z)/Math.log(10) + y*t/45000;

    }

t = time in seconds between the first post and this post passed to the function
u = upvotes
d = downvotes

console.log(getRating(50000, 25, 25)); //0

But it always returns zero. Did i miss something? Thanks

edit: updated

  • 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-27T11:17:33+00:00Added an answer on May 27, 2026 at 11:17 am

    For the example input, the result is 0, so that’s correct. Does it return 0 also for other inputs?

    One thing, according to the link, you should set

    z = Math.max(1,Math.abs(x))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am reading this page http://www.cplusplus.com/doc/tutorial/exceptions.html it says if i write function() throw(); no
I tried to write a function to check key code with JavaScript. It's working
Im trying to use the WriteFile function. Ive been working off this example http://msdn.microsoft.com/en-us/library/ms900134.aspx
I tried to write a function that calculates a hamming distance between two codewords
I've tried to write a string replace function in C, which works on a
I tried to write generic function that remove the duplicate elements from array. public
So I'm trying to make an incrementer similar to this: http://www.usagain.com/ but I'm apparently
Currently I have a url like this http://<client_name>.website.com/index.php?function_name&cat=32 I want to set things up
Working on this page: http://www.karlsenner.dreamhosters.com/about.php and having trouble with the navigation in IE6. It
I am trying to modify the example http://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-reading-files to make function handleFileSelect(evt) return reader.result;

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.