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

The Archive Base Latest Questions

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

Another collinear-points question. This one’s twist is, I’m using integer arithmetic, and I’m looking

  • 0

Another collinear-points question. This one’s twist is, I’m using integer arithmetic, and I’m looking for exact collinearity, not a fuzzy epsilon-based test.

With inline assembly, I can get an exact answer: the x86 multiply instruction gives access to both the high and low parts of the product, both of which matter in calculating the cross product (X – A) x (B – A); I can simply OR the two halves together and test for zero. But I’m hoping there’s a way to do it in C, that’s:

  1. Overflow-proof
  2. Portable
  3. Elegant

in roughly that order. And at the same time, a way to do it that is/does NOT:

  1. involve casting to double
  2. involve using a bigger integer type – assume that I’m already using the biggest integer type available for my coordinate component type
  3. yield either false positives or false negatives.

I’m not concerned in this question about whether X is beyond the segment AB; that’s just four uninteresting comparisons.

My nightmare scenario is that I’ll have to break each coordinate component into two halves, and do long multiplication explicitly, just so I can keep track of all the high halves in the partial products. (And then having to do add-with-carry explicitly.)

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

    After some comparisons and simple checks, you can get 2 couple of positive numbers (x1,y1), (x2,y2), that you want to check if x1*y2==x2*y1.

    You can use the Euclidean algorithm to find the GCD of x1 and y1, and divide them both by the GCM. Do the same thing for (x2,y2). If you got the same couple in both cases, then both vectors have the same direction.

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

Sidebar

Related Questions

Another question related to this one . I have a List<SortableObjects> that is the
Another easy one hopefully. Let's say I have a collection like this: List<DateTime> allDates;
Another thanks to SLaks for helping me get the code this far. I'm not
Another jQuery issue... I have tried this several times using class and id elements
Another way to ask this question is: what is Inversion of Control according to
Another translation question, this may be more theoretical, but I am curious as to
another linked question is Segmentation fault while using strcpy()? I have a structure: struct
another Objective-C one for you, probably pretty obvious but I have been at this
another database structuring question, hope you guys dont mind :D i am having this
Another one regex question. How do I create a regular expression that will capture

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.