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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:53:22+00:00 2026-06-14T16:53:22+00:00

I have a function that computes a point in 3d spaced based on a

  • 0

I have a function that computes a point in 3d spaced based on a value in range [0, 1]. The problem I’m facing is, that a binary floating-point number cannot represent exactly 1.

The mathematical expression that is evaluated in the function is able to compute a value for t=1.0, but the value will never be accepted by the function because it checks if for the range before computing.

curves_error curves_bezier(curves_PointList* list, curves_Point* dest, curves_float t) {
    /* ... */
    if (t < 0 || t > 1)
        return curves_invalid_args;
    /* ... */
    return curves_no_error;
}

How can I, with this function, compute the 3d point at t=1.0? I heard something about an ELLIPSIS some time ago that I think had to do with such an issue, but I’m not sure.

Thanks

EDIT: Ok, I’m sorry. I assumed a float cannot represent exactly 1, because of the issue I’m facing. The problem may be because I was doing an iteration like this:

for (t=0; t <= 1.0; t += 0.1) {
    curves_error error = curves_bezier(points, point, t);
    if (error != curves_no_error)
        printf("Error with t = %f.\n", t);
    else
        printf("t = %f is ok.\n", t);
}
  • 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-14T16:53:23+00:00Added an answer on June 14, 2026 at 4:53 pm
    for (t=0; t <= 1.0; t += 0.1) {
    

    your problem is that a binary floating point number cannot exactly represent 0.1.

    The closest 32-bit single precision IEEE754 floating point number is 0.100000001490116119384765625 and the closest 64-bit double precision one 0.1000000000000000055511151231257827021181583404541015625. If the arithmetic is performed strictly at 32-bit precision, the result of adding 0.1f ten times to 0 is

    1.00000011920928955078125
    

    If intermediate computations are performed at greater precision than float has, it could result in exactly 1.0 or even slightly smaller numbers.

    To fix your problem, in this case you could use

    for(k = 0; k <= 10; ++k) {
        t = k*0.1;
    

    because 10 * 0.1f is exactly 1.0.

    Another option is to use a small tolerance in your curves_bezier function,

    if (t > 1 && t < 1 + epsilon) {
        t = 1;
    }
    

    for a suitably small epsilon, maybe float epsilon = 1e-6;.

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

Sidebar

Related Questions

Problem I have computed a probability density function that depends on two variables. I
I have to write a function that computes and returns the maximum benefit we
I have a function that computes product of numbers in an array. The function
I have code that computes the absolute value of a custom value type: public
I have a function in my program that preforms a whole bunch of floating
I have a function that iterates through all HDD's on a computer, and returns
Inside my Controller i have function that runs after user clicks on item, which
So I have function that formats a date to coerce to given enum DateType{CURRENT,
In my Java code I have function that gets file from the client in
I have function Start() that is fired on ready. When I click on .ExampleClick

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.