Integer Questions
Ad
Why is an incremental increase to an integer in C causing overflow?
I'm working through cs50 and am currently working on a small function to determine the winner(s) of an election. void
if(fp != EOF) -> Warning: Comparison between pointer and integer
#include <stdio.h> #include <stdlib.h> int main() { file *fp; char written[]= "this is not as easy as i thought
Fastest way of checking the condition l+1<r for int l,r in Java
What is the fastest way of checking the condition l + 1 < r for int l,r in java?
Java's L number (long) specification
It appears that when you type in a number in java, the compiler automatically reads it as an integer, which is why when you type in (long)
Why does addition of long variables cause concatenation?
What does java do with long variables while performing addition? wrong version 1: vector speeds = ... //whatever,
When I enter the value 200000 as an input for a long variable, C program crashes, why?
For the simple code below, whenever i enter the value 200,000 (or any other high value), the program crashes: long size;
When is a Python Overflow Error generated?
Why do the below three lines produce different output in python3, despite the values being equal? >>> 10 ** 500
Why does repeated multiplication panic due to overflow in debug mode, when it outputs only zeroes in release mode?
I wrote this code: fn main() { let mut k: i64 = 1; loop { k = k * 10; println!("cool {}", k);
Compare and swap value in atomic integer kotlin
Hey i am learning atomic integer in kotlin. i want to know is there atomic integer swap value if current value is smaller than new value. for
Is there a way to convert a base 2^64 number to its base10 value in string form or display it in standard out in C or C++ without using big num libs?
Let's say i have a very large number represented using an array of unsigned long(int64), and i want to see its base10 form either
Ad
Flutter intl missing flutter_gen files
Anyone had a problem with flutter intl package? i keep getting the same import error, but the strings are actually working. the
How to differentiate between a number and a letter or sign?
If i have a digit within a string i can just do: x = "2" x.isdigit() and i get true. but when i do
how to convert string to vector<int> c++
I would like to convert an string into a vector, so that it looks like the following: string number = "0110"; vector <
Why is the BigInteger.ModPow function in C# much slower than that in Java?
I have found that the biginteger.modpow function in c# is very slow compared to the biginteger.modpow function in java.
Convert "Xh Xm" string into integer
Simply put i have the following string "105h 28m". using javascript, i'd like to convert it into an integer (milliseconds?)
Dividing time by an integer in PHP and Laravel
I want to divide time interval by an integer in php or laravel. $vidduration =
How to convert an array of string integers to an array of integers? Ruby
I have an array: all_ages = ["11", "9", "10", "8", "9"] and i
(c#) How do I add an integer to a string using Console.WriteLine?
I'm currently writing a program in c# and i'm practicing using integers. i'm trying to make it so the written line comes out with the int at the
How to convert an integer variable from excel to date and time in R
I have a large dataset with time stamps. the original data contained the time format like this: short-weekday, day
Operating on numpy array gives incorrect values for large numbers
I need to operate on some pretty large numbers. here, i am trying to take the cube of a large number inside an array. import numpy
Error: Integers argument expected, got float
I've just tried to copy some game code from youtube. after running the code, it gives the following the error: integers
Ad
why my database still showing 2147483647 error?
I have problem with my database due to the capacity of the variable. so, i changed my id from
Change int value to 0 via button
I am developing an counter app, and i have this floating action button which displays the amount of times it's been clicked. i want to create a
Check if two numbers have same digits
I need to write a program which will check if two numbers have same digits. for example: a = 4423, b = 2433; even
Add int data to Firestore
I'm starting to use firebase and flutter and i'm trying to add data to firestore. i succeed when adding a string, but i'm having problems when
invalid literal for int() with base 10: '2,674'
Unable to convert a string to an integer. getting error: valueerror: invalid literal for int() with base 10: '2674'
Specify expected outcome in a docstring as hexadecimal?
Is there a way to specify expected integer outcomes in a
Why int is a primitive type and not a reference type in java?
String is a reference type because we can declare a string and later initialize it, so jvm does not know the values the string holds. if so even
Im trying to create a a code that count numbers divisible by 9 by putting numbers into an array and count the numbers in it
Im trying to create a a code that count numbers divisible by 9 by putting numbers into an array and count the numbers in it but it only prints 1
Java -- The return type of a function is "String" but it can return both String and int data types
Class student { string name; int age; public void setinfo(string n, int a) { this.name = n; this.age = a;
How do I access data in "int20_t"?
I got a lot of memory pieces in 512 bits. i need to write numbers in 20 bits. for example: // a piece of 512 bits memory
I am using "table field/column" as varchar type not integer type. But why trimming first 0(zero)?
Here, "phone" is a field of "employee" table and "phone" type is string/varchar. steps: 1) save one
Ad
Javascript multiplying strings
I was doing following leetcode question on multiplying
how to convert this result of calculation flutter
Wanna know how to show this result like int number var symbol = data[index]["symbol"]; double cureentprice =
How to retrieve decimal value from Integer?
I'm trying to calculate the average based on user input. now i've got the basics working, but i am only getting whole numbers as result. i want
How to make artificial underflow/ overflow?
I'd like to clamp calculations in the range of 0-360 in my program. i know if you have an 8-bit integer adding 255 + 1 will overflow to 0 and
Parsing java long value to String in Kotlin
I have a java class that is generate by apolloclient framework. in generally , all of my code is written in kotlin. there is a problem
TypeError: range() integer end argument expected, got int
I'm using squish 6.4.2 to test my qt applications, using python 2.7.10 as the test scripting language and got the following error message when
how to properly parse String containing custom data (Semantic Versioning data)?
{ "android_version": "1.0.0", "ios_version": "1.0.0" } i have this json
In C++, why are my variable inputs that are separated by a space being stored incorrectly?
In this code i ask the user for inputs separated by a space, gradeone space gradetwo. however, it is not functioning as intended so i added output
flutter int got to zero
I have a screen with a one button and anotherone with a container to show a number. i declared a variable in the statlesswidget class. the button
Unhandled Exception: type 'int' is not a subtype of type 'String' in flutter
I cannot resolve this problem. finally i want to display 'workout.count' in main widget main.dart padding(
Python DataFrames Joining Integers
Hello just a quick question before i try something what can't work, i want to produce dataframes with only ints in it, positive and
Ad
Why will Rust integer types be deprecated soon?
I've noticed a deprecation note on the rust std page next to
Returning second highest element of a list using just a for loop and Len() method
I need two different ways for getting the second highest value of an int from a list by just using one for loop and the len() method. no other
Integer Object (Unicode) to Characterobject
:)i am pretty new to coding! my question is as following: i have a method which gets a integer object i as a parameter and this integer is
transform hex to binary and vice versa, but keeping them as integers
I know how to transform a hexadecimal integer into a binary string using the bin function, but is there an easy way to transform a hex integer
How to convert a string number into an integer in Java?
I have imported a text file into my program that contains several scores from a gamer. i am in need of adding the scores from each gamer - while
Maximum and minimum value of C types integers from Python
I'm looking for a way to get (using python) the maximum and minimum values of c types integers (ie uint8, int8,
getIntger() -> getLong()?
I use android studio. for example if "int" is like this. <integer name="test_int">1</integer>
Is there an efficient way to change all the elements in a list such that the lowest number becomes a zero, and each number after has integer spacing?
I want to achieve the following in general, and ideally without using a for loop to just step through each element since that seems inefficient.
Sending multiple integers with intent
I am trying to send two values to another page, but everytime only one of them is working.here is my code: sending: intent i = new
Use Variable outside Firebase Block
Hello everyone i'm using firebase for my ios project ... i have a lot of trouble using the values of my variables outside of the firebase blocks
SQL Query Mathematic operation
I exec below code in sql server management studio select cast (9/100 as decimal(8,3)) this should return
Ad
Javascript: toString(36) for large integers
15955067621307336078.tostring(36); returns '3d7vzfy5k2as8' in javascript because the large integer cannot be represented
Largest/smallest (NOT min/max) of a list of integers (negatives included)
(i couldn't find any min/max examples using negative integers.) i am trying to write a simple program that will find the "largest" and
Which kind of signed integer division corresponds to bit shift?
It is a familiar fact that when dividing integers by a power of two, a good compiler will strength-reduce this to bit shift. for
Adding integer to pointer
So, i was messing around with pointers in c int o = 10; int x = 20; int *pa = null; pa = &o; and after adding
Multiply 64b x 32b divide by 64b integers
What is the fastest and cross platform/compiler (gcc and msvc) way to multiply 64b x 32b divide by 64b integers like: uint64_t
Generally, How do I prevent integer overflow from happening in C language?
Generally, how can i prevent integer overflow from happening in c programming language? i mean, is there any functions to prevent? and
Why does integer division round down in many scripting languages?
In the languages i have tested, - (x div y ) is not equal to -x div y; i have tested // in python,
ArrayList<Integer> vs ArrayList<String> - both storing values from 0 to 9 .. which takes more memory?
I was asked this question... arraylist of integer vs arraylist of string - both storing values
What does *= do?
Hey i am kinda new to c and i wanted to ask why this prints out 4 instead of 260? #include
C code exponential calculation is giving wrong result
For int value 2,015,671 this code outputs 475,739,751 long long cube(int n) { return n*n*n; }
Python Integers and elifs
I am making an ai, i want the code to understand that something is an integer elif inp==("i am", int): print("you are "x" years
Ad
How to generate a repeating integer sequence from 0 to n?
I'm trying to write some code that will create a pseudo-random integer sequence that uses every digit from 0 to n, and then repeats. the naive
How to create generic method that acts differently depending on the T?
What is the best way to create a generic method that acts differently depending on the given type without using if statements that check what type
Unable to calculate factorial , getting output as 0 in C
Tried calculating factorial of 65, got correct output. anything greater than 65 results in output of 0. shocking since i'm using unsigned long
Which numerical types can be safely casted to intptr_t?
Uintptr_t and intptr_t are numerical types big enough to contain pointers, my question is how do they relate to other
How to convert an integer to bigdecimal in Java
I want to create a method that calculates multiplication of an integer and a bigdecimal. i search on google and forums, but i didn't find
Constant in mylib.h not useable
I'm just starting out teaching myself c i've learned that it is usual to create constants in mylib.h using #define constant = value however
Swift BigInt to [UInt8]
I am using swift 4 and am using this implementation of bigint:
How to separate integral part and fractional part in Swift? An how to transform fractional part into Int
I separated fractional part, but now i need to make that part as int. for example: 0.5 ->
C : Unable to represent negative values with signed int
I have to write a code for my university project that reads through a binary file and prints out integer values. this is just a small snippet of
Round division of unsigned integers with no overflow
I'm looking for an overflow-safe method to perform round division of unsigned integers. i have this: uint rounddiv(uint n,
I learned that in C language char type ranges from -128 to 127, but it doesn't seem like that
This might be a very basic problem, but i couldn't manage to. here is what i am working with.
Ad
Bit-shifting unsigned longs in C
I found a bug in a piece of code i wrote, and have fixed it, but still can't explain what was happening. it boils down to this:
Why is /=2 different from >>=1 for signed integers, and compiles to different asm?
Unsigned int a=200; //mov dword ptr [a],0c8h a >>= 1; //mov eax,dword ptr [a] //shr eax,1 //mov dword ptr [a],eax a
How to find the length(number of digits)of a long in C?
This is the code prompting the user for input #include <stdio.h> #include <cs50.h> //prompt user for number int
How to do a string to long int?
I want to create a function to take a string like this "2014-02-13t06:20:00" and to convert to a long long int
How to get bytes of integer in C?
The question is how to get bytes numbers from an integer without "0"? i mean when i want to: printf("%x", 67305985);
What does it means by "%d converts the rest of the input to integer"?
See this answer i understood it except for the last statement.
Why does it make a difference if left and right shift are used together in one expression or not?
I have the following code: unsigned char x = 255; printf("%x\n", x); // ff unsigned char tmp
How can I check if the result of a division is an integer in C?
I need to check if the result of a mathematical division is an integer or not. for example, 8 / 2 = 4 is ok. but 5 / 2 = 2.5 shouldn't
uint vs. unsigned int - Why not typedef uint?
I was wondering if there are any side-effects defining uint. typedef unsigned int uint;
Using logical operators on integers in C
logical or and logical and operator on integers in c can you explain me why the values of a,b,c are 11,10,1
How to return a error code from a function which creates structures dynamically
I return a error code from create_node function so that if memory not available it returns to the main and the program ends. i get an error that
Ad
Negation operator on unsigned char
#include <stdio.h> int main() { unsigned char a = 5; printf("%d\n",~a); printf("%d\n",a=~a); return 0; }
How do you use clang's new custom size int feature?
Recently, i heard that clang got a new feature, _extint. i know that it lets you specify the size of an integer (odd or even like
Big Integer Problem While Dealing With Factorials
The following code has a problem that i can't solve: #include <stdio.h> #include <stdlib.h> int factorial(long long
Kotlin - How to write Code to get "Sum of all divisors of an integer"
Hallo, i am very new to kotlin and one of my task is write a code to get sum of all divisors of an integer. its doesnt matter
Adding large integer values in C
This is a fairly simple question: how to get 2 unsigned integer values and add them in c for the following input
Can we left shift a value inside a while loop?
I try to make use of a left shift to identify a setbit using a counter. when i try to left shift var, i found that it is stuck in an infinite loop
MISRA Violation 12.9 Operand of unary minus is unsigned
I'm currently dealing with some misra issues and therefore trying to understand the integer conversion rules in c. i'm getting a violation
what did printf do here?
Just i was testing my understanding of pointers, while doing so i did this, okay this is what i think. all pointers to any type hold
Openmp with more than INT_MAX iterations - is it legal?
Here is a loop that works perfectly fine: #include <inttypes.h> #include <iostream> int main() { for (int32_t i = -2;
Why is this for loop with an unsigned int endless?
For (unsigned i = 0; i < 3; i++) { if (i == 2) i = -1; } i can't understand why this loop is infinite. i get that
Separating digits from a float
I need a simple function that has 3 variables: l (left), m (middle), and r (right) so int l,m,r and when i put
Ad
Is there any proper way how to put integer into string? [C]
I have code like this: char str[100]; int r = 0; for(int k = 0; k < i;k++){ str[r++] = y[k]; sprintf(str[r], str,
Why do I get a warning when using an int variable but not when using an integer constant?
I have two versions of a piece of code. the first is by using an int variable as part of an expression for a condition test, the
Ad
Blog Categories
Ad