integer

Does Lua make use of 64-bit integers?

Does Lua make use of 64-bit integers? How do I use it? ...

django store incremental numeric values in a table?

i want to make a rank application, that will calculate the rank of each course uploaded on a platform. Is it a good approach to have stored in a table values like number of downloads, and number of views, like that? class Courserate(models.Model): course = models.ForeignKey(Courses) downloads = models.IntegerField(editable = F...

Increment property int (self.int++)

How can you increment a integer property? You can't do self.integer++, you can do integer++, but I'm not sure wether or not that will retain it.. Will the last one retain the value of "integer"? Thanks. ...

Ruby on Rails: Interpreting a form input as an integer

I've got a form that allows the user to put together a hash. The hashes desired end format would be something like this: {1 => "a", 2 => "x", 3 => "m"} I can build up something similar by having lots of inputs that have internal brackets in their names: <%= hidden_field_tag "article[1]", :value => a %> However, the end result is t...

C/C++ equivalent to java Integer.toHexString

C/C++ equivalent to java Integer.toHexString. Porting some code from java to C/C++, does C have a build in function to Integer.toHexString in java? UPDATE: Heres is the exact code i'm trying to port: String downsize = Integer.toHexString(decimal); ...

Why does int num = Integer.getInteger("123") throw NullPointerException?

hi, the following code throws NPE for me: int num = Integer.getInteger("123"); is my compiler invoking getInteger on null since it's static? that doesn't make any sense! can someone explain what's happening? thanks. ...

is_int() cannot check $_GET in PHP?

Here is my code: <?php $id = $_GET["id"]; if (is_int($id) === FALSE) { header('HTTP/1.1 404 Not Found'); exit('404, page not found'); } ?> It always enters inside the if. ...

Consensus? MySQL, Signed VS Unsigned Primary/Foreign Keys

Hello, I have seen a couple threads about what everyone was doing now a days in regards to signed vs unsigned key values. It would seem that unsigned is optimal since it allows twice the number of rows for the same cost. Are there any benefits with signed keys? Is there any standard consensus? Its seems like signed is the answer since "...

How to de-interleave bits (UnMortonizing?)

What is the most efficient way to de-interleave bits from a 32 bit int? For this particular case, I'm only concerned about the odd bits, although I'm sure it's simple to generalize any solution to both sets. For example, I want to convert 0b01000101 into 0b1011. What's the quickest way? EDIT: In this application, I can guarantee t...

Does a range of integers contain at least one perfect square?

Given two integers a and b, is there an efficient way to test whether there is another integer n such that a ≤ n2 < b? I do not need to know n, only whether at least one such n exists or not, so I hope to avoid computing square roots of any numbers in the interval. Although testing whether an individual integer is a perfect square is f...

Convert integer into its character equivilent in Javascript

I want to convert an integer into its character equivalent based on the alphabet. For example: 0 => a 1 => b 2 => c 3 => d etc. I could build an array and just look it up when I need it but I'm wondering if there's a built in function to do this for me? All the examples i've found via Google are working with ASCII values and not a cha...

String to Integer not working

Humm... I can do this easily in Java (and all other languages) but, it doesn't seem to work in Android. I simply want to get an integer number input from the user, press a button and do some simple math on it, then display it. I'm using a TextEdit (also tried a TextView) and have tried many different approaches but, none work. The cod...

Why biasing towards negative numbers ?

If on my compiler, int is of 16 bits, then it's range is -32768 to 32767(in a 2's complement machine). I want to know why negative numbers have 1 extra no. i.e positive numbers go to 32767 but negative go to one more i.e.-32768. How -32768 is represented on a 2's complement m/c? ...

[iPhone app] Round division to upper integer

Hello, is there a simple way to round the result of a division to upper integer ? I would like to have this : 18/20 -> 1 19/20 -> 1 20/20 -> 1 21/20 -> 2 22/20 -> 2 23/20 -> 2 ... and so on ... 38/20 -> 2 39/20 -> 2 40/20 -> 2 41/20 -> 3 42/20 -> 3 43/20 -> 3 Must I manager with NSNumberFormatter stuff ? I didn't success to get ...

Join MSB and LSB of a 16 bit signed integer (two's complement)

I'm working with a proprietary protocol that transmits integers as 16 bit two's complement in two parts. The LSB is transmitted first followed by the MSB. Is the following code to restore the original value correct? unsigned char message[BLK_SIZE]; // read LSB to message[0] and MSB to message[1] short my_int = (message[1] << 8) | messag...

What's the easiest way to convert Int32's bytes to String?

Dim intChunkId As Integer = &H4D546864 Dim strCunnkId As String = "MThd" Dim easiestWay = GetString(intChunkId) ...

Are there any solid large integer implementations in C?

I am working on a project where I need to crunch large integers (like 3^361) with absolute precision and as much speed as possible. C is the fastest language I am familiar with, so I am trying to code my solution in that language. The problem is that I have not been able to find a good implementation of any data types for representing l...

SQL: Is it efficient to use tinyint instead of Integer if my max value is 255 ?

Lets assume I want to save the count of datagrid rows which can be max. 24 because each row is 1 hour. To save the row index in the database a tinyint field would be totally enough. But back in my mind I remember slightly that databases are optimized for integers?! So is it worth to use tinyint? ...

Convert Float to Integer Equivalent

I want to convert a floating point user input into its integer equivalent. I could do this by accepting an input string, say "-1.234" and then I could just explicitly convert each character to it's decimal representation. (big endian by the way). So I would just say for the example I gave, -1.234 = 1|01111111|00111011111001110110110 ...

Help with debugging unexpected takeWhile behaviour with large numbers in Haskell

Firstly, apologies for the vague title, but I'm not sure exactly what I'm asking here(!). After encountering Haskell at university, I've recently started using it in anger and so am working through the Project Euler problems as an extended Hello World, really. I've encountered a bug in one of my answers that seems to suggest a misunder...