Zirius Posted September 29, 2014 Group: Members Topic Count: 10 Topics Per Day: 0.00 Content Count: 23 Reputation: 1 Joined: 07/22/14 Last Seen: June 13, 2016 Share Posted September 29, 2014 Hello! I am trying to announce the current rates of my server. But they are not multiple of 100. If my base rate is 175 I want to show 1.75 by dividing by 100. But when I divide it floor() the result, resulting only on showing 1. How to do this? Quote Link to comment Share on other sites More sharing options...
Emistry Posted September 30, 2014 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted September 30, 2014 .@i = 175; announce sprintf( "%d.%02dx",( .@i / 100 ),( .@i % 100 ) ),_bc_all; end; you can also try like this. 1 Quote Link to comment Share on other sites More sharing options...
Antares Posted September 29, 2014 Group: Members Topic Count: 74 Topics Per Day: 0.02 Content Count: 420 Reputation: 89 Joined: 01/30/12 Last Seen: April 29, 2023 Share Posted September 29, 2014 I don't think it's possible to make a float number in script. I think it only supports integers. So you need to trick with integers and string texts. Ofc if you don't want to read the value from your settings, then simply write the value in the text, but I suspect you want to read the val from confs. You can try the following (.@x = rate): announce "The current base rate is: "+ .@x/100 +"."+ .@x-((.@x/100)*100),0; (if the script does the flooring right after the division, then this should return first the integer part, then after the point the rest) 1 Quote Link to comment Share on other sites More sharing options...
Antares Posted October 1, 2014 Group: Members Topic Count: 74 Topics Per Day: 0.02 Content Count: 420 Reputation: 89 Joined: 01/30/12 Last Seen: April 29, 2023 Share Posted October 1, 2014 @Emistry Yes, your's much better I always overcomplicate stuff Quote Link to comment Share on other sites More sharing options...
Question
Zirius
Hello! I am trying to announce the current rates of my server. But they are not multiple of 100.
If my base rate is 175 I want to show 1.75 by dividing by 100. But when I divide it floor() the result, resulting only on showing 1.
How to do this?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.