Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
Calculate reputation percentage based on negative and positive

I have users which can receive up-votes on their posts. Example: 5 users upvote 2 users downvote. I need to calculate the percentage of positive feedback.

I try with this code:

$result=(($positive-$negative)/$negative);
$r = ($result*100);
$result = $r / 100;

The code above does not work because if i have 50 upvotes and 1 downvote, The percentage results in 49%.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If 50 votes is 100%, you need to calculate percentage for 49 votes. Here is the math:

/* 50(votes) / 100% = 49(votes) / $x% */
$x = 100 x 49 / 50;

Which is 98%

For 5 upvotes and 2 down votes you can use the same logic:

$x = 100 x 3 / 5;

Which is 60%

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda