I'm getting a hex string that needs to be converted to a signed 8-bit integer. Currently I'm converting using Int16/Int32, which will obviously not give me a negative value for an 8-bit integer. If I get the value 255 in Hex, how do I convert that to -1 in decimal? I assume I want to use an sbyte, but I'm not sure how to get that valu...
Hi!
I am struggling with very simple thing:
I receive some ids by http request as a string. I know they represent 64bit integer id numbers.
How can I convert them to the 64 bit Integers (NSNumber or NSInteger)?
Functions like:
[nsstring integerValue],
[nsstring intValue]
seems to be 32bit limited (max value:2147483647).
Any Hints?
...
Hi,
HashMap uses objects as a key. If you use int primitive as key, it uses auto boxing and create integer objects for key.
is there any hashmap implementation uses primitive types as key. I dont want autoboxing. becuase hascode of integer is also value of integer.
I am trying to create integer object pool.
regards
Trustin
...
I'm querying a NSDictionary for a value. Because I got problems I printed the object. It shows me the following:
<CFString 0x5d33630 [0x26af380]>{contents = "myDictionaryItem"} = <CFNumber 0x5d58940 [0x26af380]>{value = +1286301600, type = kCFNumberSInt64Type}
So it is of type signed 64 bit integer. So I tried to extract the value like...
I know it's ridiculous but I need it for storage optimization. Is there any good way to implement it in C++ ?
It has to be flexible enough so that I can use as normal data type e.g Vector< int20 >, operator overloading etc..
...
In Java, I have an array of integers. Is there a quick way to convert them to a string?
I.E. int[] x = new int[] {3,4,5}
x toString() should yield "345"
...
In my iPhone app, I have a appSettings.plist. This allows me, but also others to simply change some parameters. One of the parameters is the predominant color of the app. The .plist looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd...
how to convert -1 to 1 with javascript ?
var count = -1; //or any other number -2 -3 -4 -5 ...
or
var count = 1; //or any other number 2 3 4 5 ...
result should be
var count = 1; //or any other number 2 3 4 5 ...
...
Developing a little survey webapp, ran into problem that deals with ranges for rating type questions.
So a rating's range could be:
1..10
-5..0
-5..5
'a'..'z'
'E'..'M'
and so on
The range is stored as a pair of varchars in database (start and end of range). So range always starts off as a string input.
What is the best way to take t...
But of a confusing title so let me explain. I have an array of links like this:
http://somesite.com/videoplayback?ip=81.0.0.0&sparams=id,expire,ip,ipbits,itag,algorithm,burst,factor&fexp=905602&algorithm=throttle-factor&itag=34&ipbits=8&burst=40&sver=3&expire=1285056000&key=yt1&signature=690F9475D...
Hello,
I'm trying to format integer to 2 characters, i.e. 01, 02, 03 instead of 1, 2, 3, 4.
I've done a few google searches but could not find anything. Can @"%d" be changed to reflect 2 characters ?
timeArray = [[NSMutableArray alloc] init];
for (int i = 0; i < 25; i++){
NSString *timeValue = [NSString stringWithFormat:@"%d", i];
...
Haven't seen this "feature" anywhere else. I know that the 32nd bit is used for garbage collection. But why is it that way only for ints and not for the other basic types?
...
I'm trying to create a Ruby Hash of objects, where the keys are the object @name member:
# m is an object with an @name instance variable (a string)
myHash = {}
myHash[m.name] = m
It's giving this error:
#<TypeError: can't convert String into Integer>
Anyone know why? I'm sure that m.name is a valid string...
...
When my program gets to the line:
[userNumSequence addObject:[NSNumber numberWithInteger: sequenceNumber]];
it gets the error:
Program received signal: “EXC_BAD_ACCESS”.
All I'm wanting to do is to store an integer in the array.
// JBNumberGeneration.m
#import "JBNumberGeneration.h"
@implementation JBNumberGeneration
- (id) init...
I'm writing a program that converts a binary string to decimal. I wanted to validate my output before I get really started on this method. I have the following code:
int get_val()
{
int sum =0;
for(int num_bits = size; num_bits>0; num_bits--)
{
printf("String sub %i is %i\n", num_bits, int(bin[num...
In PHP if you go above INT_MAX it will cast it as a float, allowing very high numbers to be formed (that are non-decimal as well), is this possible to do in C++ or are the way they store floating point/double precision numbers different?
The reason why is I am wishing to benchmark large factorials, but something such as 80! is way too l...
Hello!
I had an assignment in school last week to implement a function for calculating the n:th number in the fibonacci sequence. A 'sub-assignment' was to implement it using accumulation(Might not be a correct translation) in order to give the function O(n) time complexity. This all worked fine until I tried making the function (Int ->...
Can anyone explain to me how to reverse an integer without using array or String. I got this code from online, but not really understand why + input % 10 and divide again.
while (input != 0) {
reversedNum = reversedNum * 10 + input % 10;
input = input / 10;
}
...
Heya all,
For a MMORPG World of Warcraft im trying to write a lib. Money in that games is stored as an Integer and in game currency is not an integer it's based of Gold, Silver and Copper coins.
Every 100 copper is 1 silver and every 100 silver is 1 gold.
Now I need to convert such an integer to the WoW Money format: for example
1231...
I have a problem that is quite common in the code that I am writing at the moment whereby I want to have an integer that can only exist inside a certain range where the range is [start, end). Basically I want to be able to do something like the following:
cyclic_int ci(4, 8);
ci = 4;
assert(ci == 4);
ci += 3;
assert(ci == 7);
ci += 2;
...