int

What is the difference between int and NSInteger? [duplicate]

落花浮王杯 提交于 2019-12-20 18:03:46
问题 This question already has answers here : Closed 8 years ago . Possible Duplicates: When to use NSInteger vs int? Why is there is an NSInteger? Can we use int and NSInteger interchangably? Is there any specific situation to use NSInteger only, instead of using int ? 回答1: Can we use int and NSInteger interchangably? No. On the LP64 architecture used by Apple, for modern OS X Cocoa, NSInteger is 64 bits wide. This means that if you cast an NSInteger to an int, comparisons against NSNotFound may

What is the difference between int64 and int64_t in C++?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 17:34:39
问题 I am new to c++ and coding in general. so this question might be noobish. what is the difference in using type int64 or int64_t. I saw that one of the software devs modified their source on github and all of the int64 to int64_t. 回答1: int64_t is a Standard C++ type for a signed integer of exactly 64 bits. int64 is not a standard type. The first C++ standard didn't have fixed-width types. Before int64_t was added to Standard C++, the different compilers all implemented a 64-bit type but they

Ternary operator behaviour inconsistency [duplicate]

柔情痞子 提交于 2019-12-20 17:33:05
问题 This question already has answers here : Cannot implicitly convert type 'int' to 'short' [duplicate] (9 answers) Closed 5 years ago . Following expression is ok short d = ("obj" == "obj" ) ? 1 : 2; But when you use it like below, syntax error occurs short d = (DateTime.Now == DateTime.Now) ? 1 : 2; Cannot implicitly convert type 'int' to 'short'. An explicit conversion exists (are you missing a cast?) Can anyone explain why this is so? Is there a difference between comparing string-to-string

swift convert Range<Int> to [Int]

亡梦爱人 提交于 2019-12-20 15:36:57
问题 how to convert Range to Array I tried: let min = 50 let max = 100 let intArray:[Int] = (min...max) get error Range<Int> is not convertible to [Int] I also tried: let intArray:[Int] = [min...max] and let intArray:[Int] = (min...max) as [Int] they don't work either. 回答1: You need to create an Array<Int> using the Range<Int> rather than cast ing it. let intArray: [Int] = Array(min...max) 回答2: Put the Range in the init. let intArray = [Int](min...max) 回答3: do: let intArray = Array(min...max) This

Comparing two sorted int arrays

。_饼干妹妹 提交于 2019-12-20 12:23:12
问题 I have millions of fixed-size (100) int arrays. Each array is sorted and has unique elements. For each array, I want to find all arrays which have 70% common elements. Right now I am getting around 1 million comparisons (using Arrays.binarySearch()) per second, which is too slow for us. Can anyone recommend a better searching algorithm? 回答1: Something like this should do the job (provided that the arrays are sorted and contain unique elements): public static boolean atLeastNMatchingElements

How to convert QString to int?

风流意气都作罢 提交于 2019-12-20 09:46:33
问题 I have a QString in my sources. So I need to convert it to integer without "Kb". I tried Abcd.toInt() but it does not work. QString Abcd = "123.5 Kb" 回答1: You don't have all digit characters in your string. So you have to split by space QString Abcd = "123.5 Kb"; Abcd.split(" ")[0].toInt(); //convert the first part to Int Abcd.split(" ")[0].toDouble(); //convert the first part to double Abcd.split(" ")[0].toFloat(); //convert the first part to float Update : I am updating an old answer. That

convert from long long to int and the other way back in c++

自古美人都是妖i 提交于 2019-12-20 09:38:07
问题 How to convert from long long to int and the other way back in c++ ?? also what are the properties of long long , especially its maximum size, thank in advance .. 回答1: Type long long is typically 64 bits. Type int is likely to be 32 bits, but not on all machines. If you cast an int to a long long, you can do my_long_long = (long long) my_int and it will be just fine. If you go the other direction, like my_int = (int) my_long_long and the int is smaller than 64-bits, it won't be able to hold

C job interview - casting and comparing

蓝咒 提交于 2019-12-20 09:32:12
问题 I was confronted with a tricky (IMO) question. I needed to compare two MAC addresses, in the most efficient manner. The only thought that crossed my mind in that moment was the trivial solution - a for loop, and comparing locations, and so I did, but the interviewer was aiming to casting. The MAC definition: typedef struct macA { char data[6]; } MAC; And the function is (the one I was asked to implement): int isEqual(MAC* addr1, MAC* addr2) { int i; for(i = 0; i<6; i++) { if(addr1->data[i] !=

How do you create a random 64 bit number? [closed]

丶灬走出姿态 提交于 2019-12-20 07:48:46
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have part of a spec that requires me to create a random 64 bit number with the following converted to a character string : (0 to 2^63 - 1) I have no idea what this means in the brackets, can anyone help? 回答1: The parenthesis is set-builder notation for a random 64 bit number between 0 and 2^63-1, not including

Signed int range confusion

倖福魔咒の 提交于 2019-12-20 07:39:43
问题 This question might be very basic but i post here only after days of googling and for my proper basic understanding of signed integers in C. Actually some say signed int has range -32767 to 32767 and others say it has range -32768 to 32767 Let us have int a=5 (signed / let us consider just 1 byte) *the 1st representation of a=5 is represented as 00000101 as a positive number and a=-5 is represented as 10000101 (so range -32767 to 32767 justified) (here the msb/sign bit is 1/0 the number will