Raised This Month: $ Target: $400
 0% 

Solved Nonsense Divide


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-21-2021 , 22:25   Re: Nonsense Divide
Reply With Quote #3

Quote:
Originally Posted by ConorCC View Post
Hello there!

Can some explain why

static item_count; item_count = 0;
client_print(id, print_chat, "Item Count: %i | Page: %i", item_count, (item_count - 1) / 7);

prints "Item Count: 0 | Page: -1"

instead of

prints "Item Count: 0 | Page: 0"

So why -1 divided by 7 is -1 instead of 0? Shouldn't be it zero?

Please don't think me stupid.
Instinctively, I would expect it to be zero. I created a quick C++ application on Linux and it's properly showing -1/7 = 0.

More importantly, I don't think item count should ever be zero. If it's zero, then there is no concept of pages so it doesn't make sense to print that value.
__________________

Last edited by fysiks; 06-21-2021 at 23:35.
fysiks is online now
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode