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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:06:57+00:00 2026-06-18T07:06:57+00:00

I want to accelerate my algorithm using long long instead of double data type.

  • 0

I want to accelerate my algorithm using long long instead of double data type. My algorithm is to find the shortest path in a directed acyclic graph (DAG). Simply, it adds the weight of an edge "E: a->b" to b, and if the new weight of b is lower than the previous one, it is updated along with its parent which is set to a.

I mean, my algorithm is simply some addition and comparison operations. The weight of edges are originally of "double", is it possible for me to multiply them to a large number and cast them to "long long". If this tweak makes my program faster and worth considering. How can I handle instability problems due to rounding big double to long long.

Thanks

  • 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-18T07:06:59+00:00Added an answer on June 18, 2026 at 7:06 am

    On i5 x64 even imul seems to about 40% faster [than double multiplication]. Integer addition should also happen in fewer cycles / better throughput. About the “inexactness” problem you should be aware that doubles can be more inexact than integers.

    Calculate which numbers cause problems when converting decimal to floating point?

    If you have access to the original data (e.g. decimal representation of the weights, multiplying them with a large power of ten should produce exact integers without any rounding artifacts. With long longs the only concern will be that of an overflow.

    How to address possible rounding instability depends on the dynamic range of your weights, and the maximum number of iterations. E.g. if your weights are all less than 1.0 and larger than 2^-52, then multiplying with 2^52 gives exact integers with no rounding errors. Then the “instability” is determined by the possibility of an overflow. (2^12 * 2^52) >= 2^64.

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

Sidebar

Related Questions

I want to using the GPU to accelerate SURF algorithm. But Actually I found
want to know why String behaves like value type while using ==. String s1
I'm using LibGdx to develop a Java-based game. I haven't decided whether I want
Accelerate framework is nice if I want to do some algebra on vectors or
I have a loop of intensive calculations, I want them to be accelerated using
I want to accelerate the compilation of a large Flash IDE project by pre-compiling
I want to make sure I am using OpenGL for 2d rendering, but SDL
hi i am using JPA hibernate as a persistance framwork all fetc type atribute
I want to use a GPU-accelerated algorithm, to perform a fast and memory saving
I'm using the accelerate framework to optimize my DSP code. There are several times

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.