Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Using (s)printf()

by Anonymous Monk
on Apr 23, 2001 at 23:27 UTC ( #74826=note: print w/replies, xml ) Need Help??


in reply to Using (s)printf()

I keep
http://www.perlmonks.org/index.pl?node=Using%20(s)printf()&lastnode_id=954
bookmarked, since it is by far the most helpful s/printf resource I have found to date.

So: having shmoozed, care to take a question ? -) I have been working with the folks who are rewriting Math::BigFloat, and we have come to a (partial) disagreement. I am of the opinion that zero should be represented, in scientific notation, with exponent == 0; i.e. by something like '0e0'. This belief is at least in part due to the fact that every printf I've encountered renders

printf '%e\n' 0

as something like

0.000000e+00

Does this representation seem reasonable to you? Is this behavior specified anywhere?
TIA, Tom_Roche@ncsu.edu

Replies are listed 'Best First'.
(tye)Re: Using (s)printf()
by tye (Sage) on Apr 23, 2001 at 23:36 UTC

    Quoting the article you like so well:

    %g same as %e or %f, whichever printf thinks is best.
    then note that
    printf "%g", 0
    produces simply "0" so 'printf thinks "0" is best'. (:

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://74826]
help
Chatterbox?
[Lady_Aleena]: Good morning Corion, I hope you have a wonderful day as well. 8)
[Corion]: Yesterday I encountered an interesting data structure problem. I have a remote program that emits events, and my client listens for these events with one-shot callbacks, that is, I register the callback and if the event gets generated that callback ...
[Lady_Aleena]: robby_dobby, every day. Chaos is my life with few controls.
[Corion]: ... gets called once. The data structure for that is just a hash of arrays, mapping the event type to a queue of registered one-shots, and the first one-shot from the queue gets removed and called.
[Corion]: But now I want to register a one-shot for two events, of which only one will arrive, so my data structure doesn't work anymore...
[Lady_Aleena]: Corion, ouchy.
[Corion]: (maybe I should write this up as a SoPW) - currently, the "most efficient" data structure I come up with is a single array which I scan for the first fitting one-shot. Not efficient but I don't expect more than five outstanding one-shots anyway
[choroba]: can't you create a meta-key corresponding to the disjunction of the events?
[robby_dobby]: Corion: Heh. This whole thing smells of Strategy Pattern or MVC pattern.
[Corion]: And performance linear to the number of registered one-shots doesn't feel that bad. Maybe I should collect statistics on how many callbacks are outstanding ;)

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2017-05-29 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?