I am storing phone numbers of varying lengths in my WPF (C#, VS 08) App.
I store them as strings. My question is about my method AddNewPhoneNo(string phoneNo).
In this method, I use Int.TryParse to validate the incoming number (i.e. not null, is numeric...). I've since realized this is probably not the best way to do this, because then...
Are these two equivalent? In other words, are the ++ and -- operators atomic?
int i = 0;
return ++i;
AtomicInteger ai = new AtomicInteger(0);
return ai.incrementAndGet();
...
Yes, the private member variable bar should be final right? But actually, in this instance, it is an atomic operation to simply read the value of an int. So is this technically thread safe?
class Foo {
private int bar;
public Foo(int bar) {
this.bar = bar;
}
public int getBar() {
return bar;
}
}
// ...
Is there any way to have Python operators line "==" and ">" return ints instead of bools. I know that I could use the int function (int(1 == 1)) or add 0 ((1 == 1) + 0) but I was wondering if there was an easy way to do it. Like when you want division to return floats you could type from __future__ import division. Is there any way to do...
I know you can convert a String to an number with read like so:
Prelude> read "3" :: Int
3
Prelude> read "3" :: Double
3.0
But how do you grab the string representation of an Int value?
...
Hello, i've got the following question:
I've got
public enum Als
{
[StringValue("Beantwoord")] Beantwoord = 0,
[StringValue("Niet beantwoord")] NietBeantwoord = 1,
[StringValue("Geselecteerd")] Geselecteerd = 2,
[StringValue("Niet geselecteerd")] NietGeselecteerd = 3,
}
with
public class Stri...
There are certain int values that a float can not represent.
However, can a double represent all values a float can represent? (My intuition says yes, since double has more fractional bits & more exponent bits, but there might be some silly gotchas that I'm missing).
Thanks!
...
private final int NUM_SOUND_FILES = 4;
private Random rnd = new Random(4);
private int mfile[] = new mfile[NUM_SOUND_FILES]; //the second mfile
//reports error everytime
mfile[0] = R.raw.sound1;
mfile[1] = R.raw.sound2;
mfile[2] = R.raw.sound3;
mfile[3] = R.raw.sound4;
int s...
I'm trying to use an integer as the numerical representation of a string, for example, storing "ABCD" as 0x41424344. However, when it comes to output, I've got to convert the integer back into 4 ASCII characters. Right now, I'm using bit shifts and masking, as follows:
int value = 0x41424344;
string s = new string (
new ...
What purpose does it serve ?
Just read an example in a book where the author has done so.
int numOfGuesses=0;
...
I heard that using shorts on 32bit system is just more inefficient than using ints. Is this the same for ints on a 64bit system?
Python recently(?) basically merged ints with long and has basically a single datatype long, right? If you are sure that your app. will only run on 64bit then, is it even conceivable (potentially a good idea...
Hello, I started working with C# a few weeks ago and I'm now in a situation where I need to build up a "bit set" flag to handle different cases in an algorithm. I have thus two options:
enum RelativePositioning
{
LEFT = 0,
RIGHT = 1,
BOTTOM = 2,
TOP = 3,
FRONT = 4,
BACK = 5
}
...
Right, so why does Java come up with this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from double to int
at rainfall.main(rainfall.java:38)
From this:
public class rainfall {
/**
* @param args
*/
public static void main(String[] args)
{
int[] numgroup;
...
In C#, when messing with that system DLLImport/(unmanaged?) code stuff, I read somewhere it's important to use Int32 exact type instead of int. Is this true? And can someone please elaborate on why it's important to do this?
...
How can I convert from an ASP.NET Unit structure to int in c#? Or reverse?
...
Here is my repository method which returns UserId ,
public IQueryable<int> getLoginStatus(string emailId, string password)
{
return (from r in taxidb.Registrations
where (r.EmailId == emailId && r.Password == password)
select r.UserId);
}
How to return UserName which is a string along with UserId... Any sugge...
Guys if the int c=10001; which is a binary value.If i want to process it like multiplying it by 10 how to do that?
...
what is an immediate inheritor of int32 in C#?
int or int16
...
What is the most efficient way to truncate a number for a specific accuracy?
...
So I have this code:
p.Value = 1;
decimal avg = p.Value * 100 / 10000;
string prntout = p.Key + " : " + avg.ToString();
Console.WriteLine(prntout);
But the program prints out 0, instead of 0.01. p.Value is an int. How do I fix that?
...