atametsa
→ round()Brings a number to the nearest whole number.
atametsa(palo, dinao)atametsa(133.8) is 134, and atametsa(133.2) is 133 — the number goes to whichever whole number is nearer.
Give it a second value and you are saying how many places after the point you want: atametsa(12.34, 1) is 12.3. Left out, it is 0, meaning a whole number.
A number exactly halfway — like 2.5 — goes up: atametsa(2.5) is 3. Below zero that means atametsa(-2.5) is -2, not -3, because -2 is the one that lies upward.
When you always want to go up, use atametsaGodimo; when you always want to go down, use atametsaTlase.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
palo | palo | The number to round. |
dinao (optional) | palo | How many places after the point to keep. Defaults to 0. |
Examples
Section titled “Examples”tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(240);
tlogelaMothalo();
metlha dipalo = [40.2, 88.9, 133.5, 176.1, 219.8];
gopheta (diri i = 0; i < 5; i = i + 1) {
metlha yaNtlha = dipalo[i];
metlha eAtametswang = atametsa(yaNtlha);
// Bogodimo jwa ntlha, ka mmala o o bofefo
tlatsaMmala(200, 210, 225);
thalaKhutlonne(50 + i * 66, 360 - yaNtlha, 22, yaNtlha);
// Bogodimo jo bo atametswang, ka mmala o o tseneletseng
tlatsaMmala(60, 120, 200);
thalaKhutlonne(56 + i * 66, 360 - eAtametswang, 10, eAtametswang);
kwala(eAtametswang);
}
}tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(18, 22, 32);
tlogelaMothalo();
metlha boleng = 12.3456;
// Dinao di le 0, 1, 2, 3 — palo e nna e nepagetse go feta
gopheta (diri i = 0; i < 4; i = i + 1) {
metlha eAtametswang = atametsa(boleng, i);
tlatsaMmala(80 + i * 45, 190, 230 - i * 30);
thalaSediko(70 + i * 90, 200, 30 + i * 22);
kwala(eAtametswang);
}
}