int newWidth = 100;
int newHeight = 100;
double ratio = 0;
if (img1.Width > img1.Height)
{
ratio = img1.Width / img1.Height;
newHeight = (int)(newHeight / ratio);
}
else
{
ratio = img1.Height / img1.Width;
newWidth = (int)(newWidth / ratio);
}
Image bmp1 = img1.GetThumbnailImage(newWidth, newHeight, null, IntPtr.Zero);
...
Hey guys,
Is it possible to limit an integer in the NSUserDefaults?
Off course you can limit it within your app but I am thinking of the TextFields in Settings.
Would be great to get some hints.
Thanks a lot.
...
I just started reading Hacker's Delight and it defines abs(-231) as -231. Why is that?
I tried printf("%x", abs(0x80000000)) on a few different systems and I get back 0x80000000 on all of them.
...
For example:
(1).SomeFunction().Equals("one")
(2).SomeFunction().Equals("two")
I really only need it for digits 1-9 in the case I'm working with, should I just use a switch/select case?
Update I won't need localization in this case either.
Update 2 Here's what I ended up using:
Private Enum EnglishDigit As Integer
zero
one
...
I'd like to be able to pull users from a database using either a supplied e-mail address or the user id (an integer). To do this, I have to detect if the supplied string is an integer, or an e-mail. Looking for the fastest way to do this. Thanks.
def __init__(self, data):
#populate class data
self._fetchInfo(data)
def _fetc...
What are the different techniques for a floating point type to an integer type conversion, in c++?
...
It seems all of them take 4 bytes of space,
so what's the difference?
...
I want to check if user input a positive integer number.
1 = true
+10 = true
.1 = false
-1 = false
10.5 = false
Just a positive number.
No characters.
No special character.
No dot.
No minus sign.
I tried is_int() function but it is returning false even on positive integers. Is there a string to int problem?
Thanks
...
Hi.
#include <stdio.h>
main()
{
int a;
for(a=1; a<=4 && printf("%d ",a); a++)
{
int a;
static int b=a;
printf("%d ",(a++)-b);
}
getchar();
getchar();
}
In this code, the printout is 1 0 2 1 3 2 4 3. I understand why the int a; part works differently than the int a which was defined ou...
Hi,
I was wondering, what would be the best way to validate an integer.
I'd like this to work with strings as well, so I could to something like
(string)+00003 -> (int)3 (valid)
(string)-027 -> (int)-27 (valid)
(int)33 -> (int)33 (valid)
(string)'33a' -> (FALSE) (invalid)
That is what i've go so far:
function parseInt($int){
/...
How do I perform a mod operation between two integers in C++?
...
Original problem:
What is the right column format for a unix timestamp?
The net is full of confusion: some posts claim SQLite has no unsigned types - either whatsoever, or with exception of the 64bit int type (but there are (counter-)examples that invoke UNSIGNED INTEGER). The data types page mentions it only in a bigint example. It als...
I'm writing a client application to communicate with a server program via UDP. The client periodically makes requests for data and needs to use the most recent server response. The request message has a 16-bit unsigned counter field that is echoed by the server so I can pair requests with server responses.
Since it's UDP, I have to ha...
Autoboxing is rather scary. While I fully understand the difference between == and .equals I can't but help have the follow bug the hell out of me:
final List<Integer> foo = Arrays.asList(1, 1000);
final List<Integer> bar = Arrays.asList(1, 1000);
System.out.println(foo.get(0) == bar.get(0));
System.out.println(foo.get(...
Sorry if this question is answered already, but I didn't find a suitable answer.
I am having a string expression in C# which I need to convert to an int or decimal value.
For example:
string strExp = "10+20+30";
the output should be 60.
how shall I do that???
...
I have set up the user defaults to record a integer for a UISlider, the problem is that, if the user has only just installed the app then the integer is zero or NULL. Is there a way to detect if it = NULL with a integer?
heres my code i have so far:
-(void)awakeFromNib {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
se...
I am having some speed issues with my C# program and identified that this percentage calculation is causing a slow down. The calculation is simply n/d * 100. Both the numerator and denominator can be any integer number. The numerator can never be greater than the denominator and is never negative. Therefore, the result is always from ...
hi
I am working on GPU device which has very high division integer latency, several hundred cycles. I am looking to optimize divisions.
All divisions by denominator which is in a set { 1,3,6,10 }, however numerator is a runtime positive value, roughly 32000 or less. due to memory constraints, lookup table may not be a good option.
Ca...
Hello.
I have an array with integers of values from 0 to 100. I wish to remove integers that are less than number X and keep the ones that are equal or greater than number X.
I am using PHP.
Thanks!
...
I have the following code:
l = ['-1.2', '0.0', '1']
x = 100.0
for i in l:
if i < x:
x = i
print x
The code should find the lowest value in my list (-1.2) but instead when i print 'x' it finds the value is still 100.0
Where is my code going wrong?
...