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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:23:52+00:00 2026-06-09T10:23:52+00:00

Writing a sorting algorithm based off of Reddit’s here: http://amix.dk/blog/post/19588 I’m having a little

  • 0

Writing a sorting algorithm based off of Reddit’s here: http://amix.dk/blog/post/19588

I’m having a little trouble getting it all to fit together because some of the System.Math signatures differ in their application.

public class Calculation
{
    protected DateTime Epoch = new DateTime(1970,1,1);

    protected int EpochSeconds(DateTime date)
    {
        var td = date - Epoch;
        return td.Days*86400 + td.Seconds + ((td.Milliseconds)/1000000);
    }

    protected int Score(int upVotes,int downVotes)
    {
        return upVotes - downVotes;
    }

    public int HotScore(int upVotes,int downVotes,DateTime date)
    {
        var s = Score(upVotes, downVotes);
        var order = Math.Log(Math.Max(Math.Abs(s), 1), 10);
        var sign = Math.Sign(s); //Edit from Jonathon Reinhart
        var seconds = EpochSeconds(date) - 1134028003;
        return Math.Round(order + sign + *seconds/45000, 7);
    }
}

Edits for more information

Specifically I’m getting an error on the last line

return Math.Round(order + sign + *seconds/45000, 7);
//error "The * or -> operator must be applied to a pointer"

“

The closest match I can find in the method signature is this:
http://msdn.microsoft.com/en-us/library/f5898377

  • 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-09T10:23:55+00:00Added an answer on June 9, 2026 at 10:23 am

    One recommendation I would make is to use Math.Sign(Int32). So:

    var sign = new int();
    if (s > 0) { sign = 1; }
    else if (s < 0) { sign = -1; }
    else { sign = 0; }
    

    Becomes:

    var sign = Math.Sign(s);
    

    Ok, so you’re having problems with this line:

    return Math.Round(order + sign + *seconds/45000, 7);
    

    Well for one, you’re probably losing the fractional part in seconds/45000, because they are both int. Cast one to double first: ((double)seconds / 45000).

    For two, you’ve likely got a syntactical error sign + *seconds. Do you mean + or *? It thinks you’re using seconds like a pointer.

    Finally, Math.Round returns a double, but your HotScore method is returning an int. I’m guessing you want that to return a double.

    My guess is that this is what you want:

    public double HotScore(int upVotes,int downVotes,DateTime date)
    {
        var score = Score(upVotes, downVotes);
        var order = Math.Log(Math.Max(Math.Abs(score), 1), 10);
        var sign = Math.Sign(score);
        var seconds = EpochSeconds(date) - 1134028003;
        return Math.Round(order + sign * ((double)seconds/45000), 7);
    }
    

    Also, I don’t think your EpochSeconds() is correct. I adapted this from here:

    public long GetEpochTime(DateTime dt) 
    { 
        var ts = dt.Subtract(Convert.ToDateTime("1/1/1970 8:00:00 AM")); 
    
        return ((((((ts.Days * 24) + ts.Hours) * 60) + ts.Minutes) * 60) + ts.Seconds); 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a piece of code for a school asignment, we're implementing sorting algorithms
I am writing a logger for a sorting function like this: bubble :: (Ord
I am writing a function with a signature like this where I am sorting
I need a solution for sorting of unix pwd file using C++ based on
I am writing string sorting and I couldn't decide whether I should use array
I'm writing a simple little game for my kids - it doesn't really matter
I am writing a list sorting extension method. My input is the list and
I'm writing my own gridview control. The problem is sorting. What is best practic
I'm writing an implementation of an R-Tree based on Guttman's original paper. I was
while writing the question subject I came across some other allmost related post ...leading

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.