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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:16:52+00:00 2026-06-12T05:16:52+00:00

This question is asked multiple time’s, but i can’t get it working… I’m working

  • 0

This question is asked multiple time’s, but i can’t get it working…

I’m working on an program that calculates the distance between two points, and the calculates the time an unit walks about it…

This is the simplefied version of what i need to do:

x = 24 
y = 23

Root of (24² + 23²) = 33.24 fields

33.24 x 30 = 997,2 minuts

997,2/60 = 16,62 hours
16: (60*0.62) = 16:37,2   
16:37: (60*0,2) = 16:37:12

So i’ve got this piece of code in C#, but it isn’t working:

first_town = "35|629";
second_town = "59|606";
snelheidUnit = 30;

string[] firstTownSplit = first_town.Split('|');
string[] secondTownSplit = second_town.Split('|');
int firstTownPart1 = Convert.ToInt32(firstTownSplit[0]);
int firstTownPart2 = Convert.ToInt32(firstTownSplit[1]);
int secondTownPart1 = Convert.ToInt32(secondTownSplit[0]);
int secondTownPart2 = Convert.ToInt32(secondTownSplit[1]);

int verschilX = firstTownPart1 - secondTownPart1;
int verschilY = firstTownPart2 - secondTownPart2;

double aantalVelden = Math.Sqrt((Math.Pow(verschilX, 2) + Math.Pow(verschilY,2)));       // Fields
double aantalMinuten = aantalVelden * snelheidUnit;             // Minuts
double aantalUren = aantalMinuten / 60;                 // Hours

TimeSpan time = TimeSpan.FromHours(aantalUren);
string FinalTime = string.Format("{0:D2}d:{1:D2}h:{2:D2}m:{3:D2}s:{4:D3}ms", time.Days, time.Hours, time.Minutes, time.Seconds, time.Milliseconds);      

The expected output should be: 00d:16h:37m:12s:772ms

But is: 00d:16h:37m:14s:772ms

The difrnce is 2 seconds. What is the bottleneck? Why is there 2 seconds difrnce between the expected output and the real output?

  • 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-12T05:16:54+00:00Added an answer on June 12, 2026 at 5:16 am

    Root of (24² + 23²) = 33.24 fields

    The square root of 1105 isn’t exactly 33.24; you only get 33.24 if you round the square root. So compare your problem description:

    33.24 x 30 = 997,2 minuts
    
    997,2/60 = 16,62 hours
    16: (60*0.62) = 16:37,2   
    16:37: (60*0,2) = 16:37:12
    

    against what happens with a more precise value for the square root:

    33.241540277189322804630581542105 * 30 = 997.24620831567968413891744626316 minutes
    less 16 hours (960 minutes) leaves 37.246208315679684138917446263157 minutes
    less 37 minutes leaves 0.246208315679684138917446263157 minutes
    which gives 14.772498940781048335046775789394 seconds
    

    which is about 2 seconds different from what you are getting

    If you want to reproduce your original calculation, you need to do something after

    double aantalVelden = Math.Sqrt((Math.Pow(verschilX, 2) + Math.Pow(verschilY,2)));       // Fields
    

    to round that in the same way as your original; for example,

    aantalVelden  = Math.Round(aantalVelden, 2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question has been asked before perhaps multiple times, but I can't get the
I know that this question has been asked multiple times already , but I
I have asked this question before and attempted to solve it multiple time but
My apologies, I've actually asked this question multiple times, but never quite understood the
I guess this question that would have already been asked here. I searched but
I know this question has been asked multiple times before, but none of the
I know this question has been asked multiple times, but nobody has been able
I'm sure that this question has already been asked, but I don't really see
I asked this question to multiple people and until now I do not have
I've seen this question asked often, but none of the proposed solutions seem to

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.