How can I determine if an integer is a multiple of 10 (i.e. 10, 20, 30, 40, etc.) in Objective-C? Thank.
BOOL isMultipleOfTen = !(someInt % 10);
if((int)myNumber % 10 == 0){ // it is } else { // it isn't }
its almost the same for all afaik languages
Purely for entertainment @Aurum Aquila
disclaimer - DO NOT! lol ... just a little fun
BOOL isDone = NO; int multiple = 1; while(!isDone){ for(int i = 1; i<11; i++){ if(i*multiple==(int)numberToCheck){ if(i==10){ //is multiple } else{ //isn't } isDone = YES; } } multiple++; }
Aurum:
NSString* aString = [NSString stringWithFormat: @"%d", (int) aNumber]; bool isMultipleOf10 = [aString hasSuffix: @"0"];
, -stringWithFormat: , , , n % 10, .
-stringWithFormat:
n % 10
0,
C
if(no%10==0){ //number in multiple of 10 } else{//reminder is not 0 //number is not in multiple of 10 }
http://unrestrictedknowledge.blogspot.com/2009/07/modulo-using-bitwise-operators.html
Source: https://habr.com/ru/post/1792762/More articles:progress bar image download - iphoneCan I sell an iPhone application containing audio generated by the Mac OSX say command? - iphoneNew version of Script # 0.6 and ASP.NET Ajax - where is MicrosoftAjaxExt.js located? - script #iPad UIPopoverController with buttons just like the Contacts app - ioswhat is caused after returning from presentModalViewController / rejectModalViewControllerAnimated: - objective-cCan I get local notification when the location changes, and my application is in the background? - iosDoes push notification not work? - iphoneThe coordinates for my Javascript game are angle based when I use Sin Cos and Tan? - javascriptCreate a simple hash value of database columns using C # .net - hashcodeBest way to check license - c ++All Articles