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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:39:03+00:00 2026-05-29T07:39:03+00:00

I’m trying to printf a __float128 using libquadmath, eg: quadmath_snprintf(s, sizeof(s), %.30Qg, f); With

  • 0

I’m trying to printf a __float128 using libquadmath, eg:

quadmath_snprintf(s, sizeof(s), "%.30Qg", f);

With the following three constaints:

  1. The output must match the following production:

     number = [ minus ] int [ frac ] [ exp ]
    
     decimal-point = %x2E       ; .
    
     digit1-9 = %x31-39         ; 1-9
    
     e = %x65 / %x45            ; e E
    
     exp = e [ minus / plus ] 1*DIGIT
    
     frac = decimal-point 1*DIGIT
    
     int = zero / ( digit1-9 *DIGIT )
    
     minus = %x2D               ; -
    
     plus = %x2B                ; +
    
     zero = %x30                ; 0
    
  2. Given any input __float128 “i” that has been printfed to a string matching the above production “s” and and then “s” is scanfed back into a __float128 “j” – “i” must be bitwise identical to “j” – ie no information should be lost. For at least some values this is not possible (NaN, Infinity), what is the complete list of those values?

  3. There should be no other string satisfying the above two criteria, that is shorter than the candidate.

Is there a quadmath_snprintf format string that satisfies the above (1, 3 and 2 when possible)? If so what is it?

What are the values of __float128 that cannot be represented accurately enough to satisfy point 2 by the above production? (eg Nan, +/-Infinity, etc) How do I detect if a __float128 is holding one of these values?

  • 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-29T07:39:05+00:00Added an answer on May 29, 2026 at 7:39 am

    If you’re on x86, then the GCC __float128 type is a software implementation of the IEEE 754-2008 binary128 format. The IEEE 754 standard requires that a binary -> char -> binary roundtrip recovers the original value if the character representation contains 36 significant (decimal) digits. Thus the format string %.36Qg ought to do it.

    It is not required that a NaN roundtrip recover the original bitwise value.

    As for your requirement #3, libquadmath does not contain code for this kind of “shortest representation” formatting, e.g. in the spirit of the Steele & White paper or the code by David Gay.

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.