Calculate percent of value

@param percent
@param ofValue
@return
189196
public static Num percentOf(Object percent, Object ofValue) {
        Num _x = new Num(percent);
        Num _y = new Num(ofValue);
        Calculator cPercent = Calculator.builder().openBracket().val(_x).div(100).closeBracket().mul(_y);
        return cPercent.calculate();
    }
45030
def percentOfTotal(self, value, values):
        
        try:
            return float(values.index(value) + 1) / len(values)
        except (ZeroDivisionError, ValueError):
            return 0.0
10879
static String toBar(double percentValue) { // NOPMD
		final double myPercent = Math.max(Math.min(percentValue, 100d), 0d);
		final StringBuilder sb = new StringBuilder();
		final String body = "<img src=''?resource=bar/rb_{0}.gif'' alt=''+'' title=''"
				+ I18N.createPercentFormat().format(myPercent) + "%'' />";
		final int fullBlockCount = (int) Math.floor(myPercent / (UNIT_SIZE * PARTIAL_BLOCKS));
		final int partialBlockIndex = (int) Math
				.floor((myPercent - fullBlockCount * UNIT_SIZE * PARTIAL_BLOCKS) / UNIT_SIZE);

		sb.append(MessageFormat.format(body,
				fullBlockCount > 0 || partialBlockIndex > 0 ? "a" : "a0"));

		final String fullBody = MessageFormat.format(body, PARTIAL_BLOCKS);
		for (int i = 0; i < fullBlockCount; i++) {
			sb.append(fullBody);
		}

		if (partialBlockIndex > 0) {
			final String partialBody = MessageFormat.format(body, partialBlockIndex);
			sb.append(partialBody);
		}

		final int emptyBlocks = FULL_BLOCKS - fullBlockCount - (partialBlockIndex > 0 ? 1 : 0);
		final String emptyBody = MessageFormat.format(body, 0);
		for (int i = 0; i < emptyBlocks; i++) {
			sb.append(emptyBody);
		}

		sb.append(MessageFormat.format(body, fullBlockCount == FULL_BLOCKS ? "b" : "b0"));
		return sb.toString();
	}
350534
def from_percent(position_percent):
        """"""
        if not isinstance(position_percent, int):
            raise PyVLXException("Position::position_percent_has_to_be_int")
        if position_percent < 0:
            raise PyVLXException("Position::position_percent_has_to_be_positive")
        if position_percent > 100:
            raise PyVLXException("Position::position_percent_out_of_range")
        return bytes([position_percent*2, 0])
1269117
public static <T, U> Collector<T, ?, Optional<Double>> percentRankBy(U value, Function<? super T, ? extends U> function, Comparator<? super U> comparator) {
        return collectingAndThen(
            Tuple.collectors(
                rankBy(value, function, comparator),
                count()),
            t -> t.map((rank, count) -> rank.map(r -> (double) r / count))
        );
    }
1213516
function makePercent(formatter) {
  return function percentWrapped(value) {
    if (value != null) {
      return formatter(value * 100) + '%';
    }

    return formatter(value);
  };
}
55000
func percentOf(x, total float64) Percent {
	if x < 0 || total <= 0 {
		return 0
	} else if p := round(x / total * 1e5); p <= math.MaxUint32 {
		return Percent(p)
	}
	return Percent(math.MaxUint32)
}
175247
function valueToX(value) {
    const
        rect = this.$.getBoundingClientRect(),
        percent = (value - this.min) / (this.max - this.min);
    return rect.width * percent;
}
350282
public static Range<Double> calcCI95(Double percentageValue, Integer sampleSize) {
//        GWT.log("calcCI95", null);
        GWT.log("percentageValue: " + percentageValue.toString(), null);
        GWT.log("sampleSize: " + sampleSize, null);
        if (sampleSize==0) {
            return null;
        }
        if ( (sampleSize < 0) ||(percentageValue < 0.0) || (percentageValue > 100.0) ) {
            throw new IllegalArgumentException("sampleSize < 0, percentageValue < 0.0, or percentageValue > 100.0");
        }

        //convert percentageValue to ratio
        Double ratio = percentageValue/100.0;
        Double oneMinusRatio = 1.0 - ratio;

        Double sqrtSD = Math.sqrt(zStdDevSqrd + (4*sampleSize*ratio*oneMinusRatio));
        Double denom = 2*(sampleSize + zStdDevSqrd);

        Double lowerLimit = ((2*sampleSize*ratio) + zStdDevSqrd - (zStdDev *sqrtSD))/denom;

        Double upperLimit = ((2*sampleSize*ratio) + zStdDevSqrd + (zStdDev *sqrtSD))/denom;

        //convert back to percentages, to 1 d.p.
        lowerLimit = Math.rint(lowerLimit*1000)/10.0;
        upperLimit = Math.rint(upperLimit*1000)/10.0;

        if(lowerLimit<0.0) {
            lowerLimit = 0.0;
        }
        if(upperLimit>100.0) {
            upperLimit = 100.0;
        }

//        GWT.log("lowerLimit: " + lowerLimit.toString(), null);
//        GWT.log("upperLimit: " + upperLimit.toString(), null);
        return new Range<Double>(lowerLimit, upperLimit);
    }
230455
def percentage(self):
        """"""
        if self.currval >= self.maxval:
            return 100.0
        return self.currval * 100.0 / self.maxval
588002
def valueAt( self, percent ):
        
        minim = self.minimum()
        maxim = self.maximum()
        rtype = self.rulerType()
        
        # simple minimum
        if ( percent <= 0 ):
            return minim
        
        # simple maximum
        elif ( 1 <= percent ):
            return maxim
        
        # calculate a numeric percentage value
        elif ( rtype == XChartRuler.Type.Number ):
            return (maxim - minim) * percent
        
        # calculate a time percentage value
        elif ( rtype in (XChartRuler.Type.Datetime, XChartRuler.Type.Time) ):
            maxsecs = minim.secsTo(maxim)
            
            diff = maxssecs * percent
            return minim.addSecs(diff)
            
        # calculate a date percentage value
        elif ( rtype == XChartRuler.Type.Date ):
            maxdays = minim.daysTo(maxim)
            
            diff = maxdays * percent
            return minim.addDays(diff)
            
        # otherwise, compare against the notches
        else:
            perc    = 0.0
            notches = self.notches()
            count   = len(notches)
            count  += self.padStart() + self.padEnd()
            count   = max(1, count - 1)
            
            perc    = float(self.padStart()) / count
            last    = None
            
            for i, notch in enumerate(notches):
                perc += float(i) / count
                if ( perc <= percent ):
                    break
                
                last = notch
            
            return last
203933
public static function calculate_percentage($numerator, $denominator, $decimals = 2, $dec_point = '.', $thousands_sep = ',')
    {
        return number_format(($numerator / $denominator) * 100, $decimals, $dec_point, $thousands_sep);
    }
1293872
def formatPercent( value, options = nil )
      if value
         percent = (value.to_f * 100)
         value = percent.to_s
         if value.include?(".")
            int,fraction = value.split('.')
            if fraction.to_i == 0
               value = int
            else
               value = "#{int}.#{fraction[0,2]}"
            end            
         end         
      else
         value = "0"
      end
      value
   end
533869
private Double getPercentage(Number number)
   {
      Double result = null;

      if (number != null)
      {
         result = Double.valueOf(number.doubleValue() / 100);
      }

      return result;
   }
954729
public static <T, U> Collector<T, ?, Optional<T>> percentileBy(double percentile, Function<? super T, ? extends U> function, Comparator<? super U> comparator) {
        if (percentile < 0.0 || percentile > 1.0)
            throw new IllegalArgumentException("Percentile must be between 0.0 and 1.0");

        // At a later stage, we'll optimise this implementation in case that function is the identity function
        return Collector.of(
            () -> new ArrayList<Tuple2<T, U>>(),
            (l, v) -> l.add(tuple(v, function.apply(v))),
            (l1, l2) -> {
                l1.addAll(l2);
                return l1;
            },
            l -> {
                int size = l.size();

                if (size == 0)
                    return Optional.empty();
                else if (size == 1)
                    return Optional.of(l.get(0).v1);

                l.sort(Comparator.comparing(t -> t.v2, comparator));

                if (percentile == 0.0)
                    return Optional.of(l.get(0).v1);
                else if (percentile == 1.0)
                    return Optional.of(l.get(size - 1).v1);

                // x.5 should be rounded down
                return Optional.of(l.get((int) -Math.round(-(size * percentile + 0.5)) - 1).v1);
            }
        );
    }
807751
static public <C, T extends C> Value<C, T> percentWidth (Toolkit<C, T> toolkit, final float percent) {
		return new TableValue<C, T>(toolkit) {
                        @Override
			public float get (T table) {
				return toolkit.getWidth(table) * percent;
			}
		};
	}
1156164
def percent(self, value) -> 'Gap':
        """"""
        raise_not_number(value)
        self.gap = '{}%'.format(value)
        return self