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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:24:03+00:00 2026-05-23T00:24:03+00:00

Ok, I do know what and how works floating point. But, It doesn’t stop

  • 0

Ok, I do know what and how works floating point. But, It doesn’t stop to puzzle me whenever I deal with it.

I try to do some time axis generation function. The idea is simple. To make smt like this

(defun make-time-axis (start step stop)
  ...)

So, when you call it with e.g.

(make-time-axis 0 0.1 1.2)

result will be

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 

But whenever I do whatever

(loop for i from 0.0 below 1.2 by 0.1 collect i)

or

(defun make-time-axis (last step stop)
  (cond  ((< last stop ) (cons last (make-time-axis (+ last step) step stop )))
     (t nil)))

etc.

I getting these results

(0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.70000005 0.8000001 0.9000001 1.0000001 1.1000001)

Can anybode give me some clue how to get What I want?

  • 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-23T00:24:04+00:00Added an answer on May 23, 2026 at 12:24 am

    If you know how floating point works (you have read What Every Computer Scientist Should Know About Floating Point Arithmetic, right?), you should realize that you got exactly what you asked for.

    Mathematical numbers (be they integers, rationals, reals, complex, whatever) have many useful properties. For example, x/10 + y/10 = (x+y)/10. These properties don’t hold for floating point numbers.

    Given your numerical results, it seems that in your implementation, the value of the floating-point number 0.1 is slightly above the value of the mathematical number 0.1 (which isn’t exactly representable as floating point). When you add it up several times, the error eventually rises above the printing precision.

    Since you’re using Lisp, it’s easy to retain numbers in exact form (e.g. the rational 1/10 instead of the float 0.1) and convert them at the last minute.

    (loop for i from 0 below 12/10 by 1/10 collect (float i))
    (mapcar #'float (make-time-axis 0 1/10 12/10))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As we all know, floating point arithmetic is not always completely accurate, but how
I try to store the PHP floating point value 63.59072952118762 into a double precision
First of all, I'm not looking for miracle... I know how PHP works and
I would like to know exactly how the Is command works in Linux and
I would like to know what of the many XSLT engines out there works
I am a little curious to know about how OpenID authentication works. Is there
As you may already know, the .NET Framework's protected internal access modifier works in
Alright, I know how the fieldset / legend works out in HTML. Say you
I know what MVC is and I work in webforms but I don't know
I know that XSLT does not work in procedural terms, but unfortunately I have

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.