Thank you Matthew. The new docs are crystal clear on what I want. Thank you.

Jay

On Mon, Apr 25, 2016 at 10:50 AM, Matthew Flatt <mfl...@cs.utah.edu> wrote:
> I agree that the spec for printing inexacts needs to be clarified.
>
> The current output format for flonums is consistent with scanf(), at
> least for non-infinity and non-NaN values, since it's produced by
> sprintf("%g", ...). Using "%g" means that the number sometimes prints
> with an "e..." part and sometimes not, though.
>
> For single- or extended-precision numbers, the output always includes
> an "f" or "t", and converting that character to "e" makes it compatible
> with scanf().
>
> At Mon, 25 Apr 2016 08:37:32 -0400, Jay McCarthy wrote:
>> Interesting. FWIW, my particular interest is something that I can
>> reliably send to other tools like Unix's bc or C's scanf. Going down
>> this line, however, did make me question using `number->string` all
>> over the place in demo Web programs.
>>
>> On Fri, Apr 22, 2016 at 10:22 AM, Robby Findler
>> <ro...@eecs.northwestern.edu> wrote:
>> > I think number->string is intended to be like `write` (ie written to
>> > be read back in hopefully without losing anything) and maybe you want
>> > something that's more in the spirit of `display`? (I.e., show
>> > something to a human in a hopefully useful format (at least that's how
>> > I see the difference between write and display)).
>> >
>> > There is a very very old attempt at this that was designed for use
>> > with DrRacket:
>> >
>> >
>> http://docs.racket-lang.org/framework/Number_Snip.html?q=number-snp#%28def._%28
>> %28lib._framework%2Fmain..rkt%29._number-snip~3amake-repeating-decimal-snip%29%
>> 29
>> >
>> > It does things like trying to make nice-looking fractions and show
>> > helpful amounts of decimals and deals with the fact that smallish
>> > rationals might turn into very very long decimals. It also requires a
>> > GUI context, so that might not be helpful.
>> >
>> > That said, I'm sure it could stand to be generalized and modernized
>> > and improved. It is used in DrRacket currently, so you can just write
>> > programs that produce numbers to play around with it.
>> >
>> > Robby
>> >
>> > On Fri, Apr 22, 2016 at 9:07 AM, Jay McCarthy <jay.mccar...@gmail.com> 
>> > wrote:
>> >> This is complicated by single-flonums which seem to pretty out in the
>> >> reading format:
>> >>
>> >> (number->string 3f0) ===> "3.0f0"
>> >>
>> >> which is likely to look like an error to users.
>> >>
>> >> This makes me feel like I should never use number->string to show
>> >> something to a user... which seems strange.
>> >>
>> >> On Wed, Apr 20, 2016 at 1:28 PM, Jay McCarthy <jay.mccar...@gmail.com>
>> wrote:
>> >>> The documentation for (number->string z radix) is a bit sparse:
>> >>> "Returns a string that is the printed form of z in the base specified
>> >>> by radix. If z is inexact, radix must be 10, otherwise the
>> >>> exn:fail:contract exception is raised."
>> >>>
>> >>> In the case that z is inexact, are we guaranteed that it will always
>> >>> print as "<Sign>?<Digit>+<Dot><Digit>+" and never use... (a) the
>> >>> #i<Digit>+ format, (b) scientific notation, (c) not have a leading 0,
>> >>> and so on?
>> >>>
>> >>> Essentially, I would like to know that (number->string z 10) on an
>> >>> inexact is equivalent to (real->decimal-string z +inf.0) (if infinity
>> >>> were a legal value for the length of the decimal.)
>> >>>
>> >>> If not, there doesn't seem to be another function that reliably prints
>> >>> out floats.
>> >>>
>> >>> Jay
>> >>>
>> >>> --
>> >>> Jay McCarthy
>> >>> Associate Professor
>> >>> PLT @ CS @ UMass Lowell
>> >>> http://jeapostrophe.github.io
>> >>>
>> >>>            "Wherefore, be not weary in well-doing,
>> >>>       for ye are laying the foundation of a great work.
>> >>> And out of small things proceedeth that which is great."
>> >>>                           - D&C 64:33
>> >>
>> >>
>> >>
>> >> --
>> >> Jay McCarthy
>> >> Associate Professor
>> >> PLT @ CS @ UMass Lowell
>> >> http://jeapostrophe.github.io
>> >>
>> >>            "Wherefore, be not weary in well-doing,
>> >>       for ye are laying the foundation of a great work.
>> >> And out of small things proceedeth that which is great."
>> >>                           - D&C 64:33
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> >> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> Jay McCarthy
>> Associate Professor
>> PLT @ CS @ UMass Lowell
>> http://jeapostrophe.github.io
>>
>>            "Wherefore, be not weary in well-doing,
>>       for ye are laying the foundation of a great work.
>> And out of small things proceedeth that which is great."
>>                           - D&C 64:33
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.



-- 
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

           "Wherefore, be not weary in well-doing,
      for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
                          - D&C 64:33

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to