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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:40:57+00:00 2026-06-09T19:40:57+00:00

does anyone know how to specify the numer of digits after the decimal point

  • 0

does anyone know how to specify the numer of digits after the decimal point for a float in Lisp?

Say if I print this command at the REPL:

CL-USER 3 > (format t "~,15f" (float (/ 1 7)))

I get:

0.142857150000000 

But the number is rounded at the 8th digit after the decimal point, I need to see a lot of digits after the decimal point in order to see if the number is cyclic and to calculate the period.
(Actually I’m starting to try and solve Project Euler’s problem 26).

I need to get something like this:

CL-USER 3 > (format t "~,15f" (float (/ 1 7)))
0.142857142857142857142857142857142857.... 

Thank you,

Luca

  • 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-09T19:40:59+00:00Added an answer on June 9, 2026 at 7:40 pm

    Common Lisp does not have floats with arbitrary exactness in its standard.

    Common Lisp defines four float types in the standard: SHORT-FLOAT, SINGLE-FLOAT, DOUBLE-FLOAT, LONG-FLOAT.

    You can coerce a ratio to a float using the function COERCE (example in LispWorks):

    CL-USER 1 > (coerce (/ 1 7) 'double-float)
    0.14285714285714285D0
    

    or as a LONG-FLOAT in CLISP

    [1]> (coerce (/ 1 7) 'long-float)
    0.14285714285714285714L0
    

    To compute with longer float numbers you need extensions to Common Lisp. GNU CLISP has a non-portable extension and can set the number of (binary) digits:

    (SETF (EXT:LONG-FLOAT-DIGITS) n)

    Example:

    [3]> (SETF (EXT:LONG-FLOAT-DIGITS) 1000)    
    1000
    [4]> (coerce (/ 1 7) 'long-float)
    0.142857142857142857142857142857142857142857142857142857
    142857142857142857142857142857142857142857142857142857
    142857142857142857142857142857142857142857142857142857
    142857142857142857142857142857142857142857142857142857
    142857142857142857142857142857142857142857142857142857
    142857142857142857142857142857142857143L0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know the correct way to explicitly specify which rules Gendarme will use?
Does anyone know the proper syntax on how to specify the model that you
Does anyone know how to specify a bean as non lazy when using annotations
Does anyone know how to do specify the Mac OS X SDK to build
I think the answer to this question is no... but does anyone know of
Does anyone know how to specify the sampling rate of the iphone GPS? I
does anyone know how to specify the height of a net.rim.device.api.browser.field2.BrowserField? I cannot find
I use VS2010 for unit testing. Does anyone know how to specify the location
Does anyone know the bash construct where you specify the delimeter and you get
Does anyone know how to specify the MRL for the default camera on mac

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.