0

I have three counters counterBoat, counterThink and counterWork.

I want to print the integer "round"(100*counterBoat/(counterBoat+ counterThink+ counterWork)) in my document.

I use the package totcount.

  • Load the xfp package and use \inteval, and use \value to access the values of the counters. The result is rounded by default. \inteval{100*\value{counterBoat}/(\value{counterBoat}+\value{counterThink}+\value{counterWork})} – Phelype Oleinik Oct 2 at 12:54
2
 \numexpr(100*\value{counterBoat}) / 
        ( \value{counterBoat} + \value{counterThink} + \value{counterWork})\relax
  • 1
    Just +1 for not using unneeded packages... My previous comment about lost parenthesis was no valid ... was a combination of edited and non edited answer ... Sorry. – koleygr Oct 2 at 12:57
  • 3
    If you want to print that number rather than use it in another calculation, prefix with \the – David Carlisle Oct 2 at 12:57
  • @koleygr your comment was valid until (literally) a second before you posted it, so no need to apologise! – David Carlisle Oct 2 at 12:58
  • 1
    @Colas as I say just put \the in front of that line in a document and the number will be printed. There is no testable code in this answer as you did not supply a test document in the question. – David Carlisle Oct 2 at 15:03
  • 1
    @Colas of course not, you are using \numexpr and counters so this is integer arithmetic. That appears to be a completely different question, perhaps you want to use the xfp package and floating point arithmetic, i really can't guess. – David Carlisle Oct 2 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.