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 know I can use Request.Browser.IsMobileDevice . But does anyone know how it works,
I know that the following works but it is not that readable, is there
I am thinking recently on how floating point math works on computers and is
I am making a toy physics engine which works with floating point numbers which
I'd like to send some double precision floating point numbers over the network. (standard
I recently realized that some countries display floating point numbers with different comma/period notation.
I like to know how works or what means(?) when you define a function
I've build a website for a client and as we all know 'it works
I know how memcached works. How does Hadoop work?

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.