Re: [racket-users] Re: number->string format guarantees

2016-04-25 Thread Jay McCarthy
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  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
>>  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  
>> > 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 
>> 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 "?++" and never use... (a) the
>> >>> #i+ 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

Re: [racket-users] Re: number->string format guarantees

2016-04-25 Thread Matthew Flatt
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
>  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  
> > 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  
> 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 "?++" and never use... (a) the
> >>> #i+ 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and st

Re: [racket-users] Re: number->string format guarantees

2016-04-25 Thread Robby Findler
Annoying that you cannot send them the floating point bits and have to
rely on their (probably complex) number parsing routines!

Robby


On Mon, Apr 25, 2016 at 7:37 AM, 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
>  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  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  
>>> 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 "?++" and never use... (a) the
 #i+ 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.

-- 
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.


Re: [racket-users] Re: number->string format guarantees

2016-04-25 Thread Matthias Felleisen
Perhaps you should introduce a library of functions with names that 
specifically point to Unix/Linux compatibility — Matthias



> On Apr 25, 2016, at 8:37 AM, 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
>  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  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  
>>> 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 "?++" and never use... (a) the
 #i+ 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.

-- 
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.


Re: [racket-users] Re: number->string format guarantees

2016-04-25 Thread Jay McCarthy
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
 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  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  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 "?++" and never use... (a) the
>>> #i+ 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.


Re: [racket-users] Re: number->string format guarantees

2016-04-22 Thread Robby Findler
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  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  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 "?++" and never use... (a) the
>> #i+ 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.

-- 
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.


[racket-users] Re: number->string format guarantees

2016-04-22 Thread Jay McCarthy
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  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 "?++" and never use... (a) the
> #i+ 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.