ID:926187   Aug 11 2012, 7:49 pm (Edited on Aug 11 2012, 7:57 pm) (See the best response by Zaoshi.) I'm wondering if it's possible to use one numerical value to set the value of four other variables. The four variables are copper for the 1s place, silver for the 10s place, gold for the 100s place and platinum for the 1000s place. They are the players currency. The item value would be translated into those four currencies, which would then be displayed individually. Like so... ```item_value=3737 = 37 copper or 3 silver 7 copper ``` ```item_value=14241424 = 1424 copper or 14 gold 2 silver 4 copper or 1 platinum 4 gold 24 copper or 1 platinum 4 gold 2 silver 4 copper ``` ```item_value=2789327893 = 27893 copper or 278 gold 9 silver 3 copper or 27 platinum 8 gold 93 copper or 27 platinum 8 gold 9 silver 3 copper ```
 <-> Aug 11 2012, 8:12 pm round() always returns the floor of the sent value. Round off for the places and divide by the value. ```item_value = 27001var/i = item_valueif(i >= 1000) platinum = round(i, 1000)/1000 // returns 27 i = i - round(i, 1000) // This takes away the thousands place, in this case leaving you with 1if(i >= 100) gold = round(i, 100)/100 i = i - round(i, 100)if(i >= 10) silver = round(i, 10)/10 i = i - round(i, 10)if(i >= 1) copper = round(i) ```
 <-> Aug 11 2012, 8:50 pm ah thanks!
 <-> Aug 11 2012, 9:07 pm In response to Albro1 Best response Albro1 wrote: round() always returns the floor of the sent value. Round off for the places and divide by the value. According to reference that is not true. Since you specify to round to 1000 it'll round to nearest, not floor My approach would be ```item_value = 1234platinum = round(item_value / 1000)gold = round(item_value % 1000 / 100)silver = round(item_value % 100 / 10)copper = item_value % 10 ```
 <-> Aug 11 2012, 9:08 pm Nothing in the reference suggests otherwise. round() always floors. In fact, the reference proves my point. In their example, they did round(-1.45), which results in -2. Therefore - floor'd.
 <-> Aug 11 2012, 9:11 pm Format: round(A) round(A,B) The first format returns the floor of A (the largest integer less than or equal to A). The second format rounds A to the nearest multiple of B. Did you even bother to read reference? round(-1.45) will floor, round(1.45,1.5) rounds.
 <-> Aug 11 2012, 9:14 pm It is only if you specify the second argument (B) that it will round to THAT value's nearest multiple. Other than that, it will always floor. It's also why we have this ceil (rounding up, instead of down) shortcut, using the usage of negatives with flooring. ```#define ceil(x) (-round(-(x))) ``` normally, round(-1.45) will become -2, and round(1.45) will become 1. to ceil a positive, you just negate it, and then negate the rounded value, thus the ceil shortcut.
 <-> Aug 11 2012, 9:16 pm It still floors. I guess you could deceive it into appearing to not floor by providing an exact amount for the second argument. Like SSX said though, it rounds to the nearest multiple. 1.45 is closer to 1.5 than it is to it's next multiple, 3.
 <-> Aug 11 2012, 9:18 pm In response to Super Saiyan X IMO round() just needs to be turned into floor() and that ceil() shortcut needs to be put into BYOND. It's a very simple thing that's been put off for far too long.
 <-> Aug 11 2012, 9:19 pm Problem is, your answer to OP's question is wrong. ```item_value = 27001platinum = round(i, 1000)/1000 // returns 27item_value = 27501platinum = round(i, 1000)/1000 // returns 28, expected 27 ```
 <-> Aug 11 2012, 9:21 pm In response to Zaoshi Thanks for pointing that out, that is a legitimate problem. I think you should thank us for pointing out your mistake before pointing out ours, though.
 <-> Aug 11 2012, 9:23 pm I can't see where I made mistake. In my very first post I told round(a) floors and round(a, b) rounds by linking reference.
 <-> Aug 11 2012, 9:24 pm In response to Zaoshi Zaoshi wrote: I told round(a) floors No, you didn't. Anyways, another solution would be to convert it to a text string and parse it.
 <-> Aug 11 2012, 9:28 pm Since you specify to round to 1000 it'll round to nearest, not floor I can't tell whether you're trolling or not.