Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

BMI- Berechnung Nachkommastellen

  • PaulusNo
  • PaulusNo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 10 months ago #215638 by PaulusNo
BMI- Berechnung Nachkommastellen was created by PaulusNo
Hallo zusammen!

Mal wieder eine Frage zur hier oft gerfragten BMI-Berechnung.
Habe das ganze mit Hilfe des Forums soweit hingebracht, jedoch gibt die Gleichung mir 15 Nachkommastellen aus.
 
Wie bekomme ich nur zwei Nachkommastellen?

Ich verwende Version 3.25.21.
Danke für Eure Hilfe!

Liebe Grüße

Paulus

 
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 10 months ago - 2 years 10 months ago #215640 by Joffm
Replied by Joffm on topic BMI- Berechnung Nachkommastellen
Hallo,
siehst Du, das ist der Vorteil des Alters.
Wir haben so etwas noch gelernt, was zu tun ist, wenn nur die Funktion "round()" für ganze Zahlen zur Verfügung steht.

Zunächst nimmst Du die Zahl mit der Zehnerpotenz mal, die Deiner gewünschten Nachkommastellenzahl entspricht.
10 für 1
100 für 2
1000 für 3
...

Also in Deinem Beispiel nimmst Du die 21,4475678... mit 100 mal und erhältst
2144,75678...
Diese rundest Du nun ganz normal und es gibt
2145 
Und jetzt machst Du den ersten Schritt wieder rückgängig, indem Du durch 100 teilst.
Voila: 21,45

In LS-Syntax

{round(BMI*100)/100}

 

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 10 months ago by Joffm.
The following user(s) said Thank You: PaulusNo
The topic has been locked.
Moderators: Joffm

Lime-years ahead

Online-surveys for every purse and purpose