more useful options PerlMonks

Comment on

 ( #3333=superdoc: print w/ replies, xml ) Need Help??
Your made yourself clear enough in the OP but you don't seem to like the answers (or won't understand them?).

The numbers in your latest post, 30, 23, and 13, happen to be what I gather your mean by a "nice" case; that is, when calculated as percentages of their total and rounded, the percentages add up (nicely) to 100.

Here's a case where the numbers are not "nice" and where a disclaimer is the only reasonable solution (fudging is NOT, IMO, reasonable):

```#!/usr/bin/perl
use strict;
use warnings;
#785290

my \$Google=30; my \$Yahoo=23; my \$Bing=12;
my \$sum=\$Google + \$Yahoo + \$Bing;

my \$yahoo_percent = \$Yahoo/\$sum;
print "\tY: \$yahoo_percent";
my \$bing_percent = \$Bing/\$sum;
print "\tB: \$bing_percent \n";

my \$total = (\$google_percent + \$yahoo_percent + \$bing_percent);

my \$roundedG = sprintf("%.2f", \$google_percent);
my \$roundedY = sprintf("%.2f", \$yahoo_percent);
my \$roundedB = sprintf("%.2f", \$bing_percent);
my \$rounded = sprintf("%.2f", \$total);
print "Google: \$roundedG; Yahoo: \$roundedY; Bing: \$roundedB; Total: \$r
+ounded \n";

print "%\n";
printf ('%.0f', ((\$Yahoo/\$sum)*100));
print "%\n";
printf ('%.0f', ((\$Bing/\$sum)*100));
print "%\n";
print \$rounded*100 . "% (Percentages may not add up to 100 because of
+rounding errors!)\n";

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Please read these before you post! —
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?
• See Writeup Formatting Tips and other pages linked from there for more info.

Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (23)
As of 2015-08-28 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?