Skip to main content
Filter by
Sorted by
Tagged with
0 votes
3 answers
96 views

I want to construct objects which support arithmetic operations and have extra methods, e.g: class Timestamp(int): def as_seconds(self): return self / 90000 The extra method works: >&...
tuserun's user avatar
  • 11
4 votes
1 answer
104 views

In love2D I have a string that represents a mathematical expression, for example: local expr1 = "[p35] div [p36]" local expr2 = "((([p35]*100) div [p36]) mod 100)" local params = {...
darkfrei's user avatar
  • 638
-1 votes
1 answer
115 views

print(krit) names weight 1 may 36 2 mayer 49 3 mayo 35 4 mali 50 > mean(krit$weight) [1] 42.5 > typeof(weight) [1] "double" > typeof(names) [1] "character&...
Belinda Omino's user avatar
Advice
1 vote
21 replies
401 views

From the man pages, I found that size_t has the range of 0 to SIZE_MAX, and ssize_t has the range of -1 to SSIZE_MAX. So, after printing those values on a 64bit system, I have the following results: ...
sat0sh1c's user avatar
1 vote
2 answers
215 views

The following code is trying to set the test array in the first for loop, but it can't be used in the second for loop. int main() { int *test[3]; /** Try to set the array value one by ...
stackbiz's user avatar
  • 1,914
2 votes
1 answer
116 views

I working on a code where it is necessary to have large integers, here is a simplified version of it (len_class.py): class BigLen(): def __len__(self): return 10**100 However I'm running ...
user126306's user avatar
4 votes
2 answers
180 views

I am trying to make my own file compressor and some of the chars in the file that I am trying to compress are '�'. I tried: #include <iostream> int main(){ std :: cout << (int)'�'; ...
Jordon's user avatar
  • 103
3 votes
2 answers
234 views

I am trying to solve a problem posed in this question which asks that a program be written that calculates logarithms of numbers without including <math.h>. I wrote the following program: #...
uran42's user avatar
  • 469
4 votes
2 answers
190 views

I'm seeing a strange (to me) difference in behavior between Clang and GCC when comparing an integer with its negation. Also, pre-v12 GCC behaves like Clang. Code is below, but also here's a live link ...
jwd's user avatar
  • 11.4k
3 votes
1 answer
106 views

The following lex rules are copied from int_literal in docs of rust nightly. INTEGER_LITERAL -> ( DEC_LITERAL | BIN_LITERAL | OCT_LITERAL | HEX_LITERAL ) SUFFIX_NO_E? DEC_LITERAL -> ...
Mike Li's user avatar
  • 81
5 votes
1 answer
136 views

I recognized that int(unicode_string) sometimes gives obscure results. E.g. int('᪐᭒') == 2. >>> bytes('᪐᭒', 'utf-8') b'\xe1\xaa\x90\xe1\xad\x92' >>> [f'U+{ord(c):04X}' for c in '᪐᭒'] ...
Wör Du Schnaffzig's user avatar
-4 votes
2 answers
126 views

This script takes lines from a file of lottery numbers, and is supposed to check for errors. For example, in the following: week 1;17,19,35,23,8,20,36 week 2;24,28,35,8,3,22 week x;23,29,38,1,35,18,25 ...
Dominic 's user avatar
0 votes
0 answers
62 views

Why is the sum of the iaea_mass_dat_trunc$AM_WN (integer) and iaea_mass_dat_trunc$AM_frac (numeric) 499496.6 for all results? How do I get the appropriate result (for example, the sum of the values in ...
Brian's user avatar
  • 117
5 votes
5 answers
422 views

I am reading modern C, and on page 66, I come across following section: Remember that value 0 is important. It is so important that it has a lot of equivalent spellings: 0, 0x0, and ’\0’ are all the ...
Nan Xiao's user avatar
  • 17.8k
1 vote
1 answer
145 views

Imagine: int full = static_cast<int>(uint8_t_var); Does anything actually happen under the hood here? If you're on a machine with 64 bit registers, I assume that the higher bits of uint8_t_var ...
bhfelliot's user avatar
  • 667
2 votes
2 answers
313 views

The float timestamp used in Python seems to be problematic. First, it will lose its precision as time goes on, and second, the timestamp is not usable, for example, storing in a database big integer ...
Yadav Dhakal's user avatar
0 votes
1 answer
35 views

OpenCL C supports "vector data types" - a fixed number of scalar types which may be operated on together, as though they were a single scalar, mostly: we can apply arithmetic and logic ...
einpoklum's user avatar
  • 138k
2 votes
2 answers
127 views

How do I convert a numeric string input from a user into an integer array in Java? What I did so far is: # Get User input System.out.println("Guess the number: "); String input = read....
its.spark.dev's user avatar
1 vote
1 answer
62 views

I have this program that is supposed to select one color channel from an image, and square each element elementwise. However, it is not returning any results greater than the values in the first array?...
Gad11ng's user avatar
  • 43
1 vote
1 answer
98 views

I have this code that separates the integer part from the decimal part import java.io.*; import java.util.Scanner; public class hoja1ej9 { public static void main(String[] args) { ...
Enrique Vara Gallardo's user avatar
-4 votes
6 answers
215 views

I'm trying to make my own video game in Unity. I have a series of biomes. They eventually evolve from bad to good, based on a float converted into an int going from 0 to 100, giving a biome Value of +...
user30342766's user avatar
0 votes
1 answer
98 views

class Solution { public: int change(int amount, vector<int>& coins) { vector<unsigned int > dp(amount+1, 0); dp[0]=1; for (int value: coins){ ...
OXEN's user avatar
  • 13
6 votes
1 answer
141 views

I was testing the behaviour of the big three (GCC, clang, MSVC). I'm not sure what is standard-compliant. Consider this code: // p43.cxx #include <type_traits> constinit auto n1 = ...
La Creatura's user avatar
1 vote
1 answer
59 views

Before issuing the ID ( took from a String list ) to the argument of a function call, I first check if it represents a number: if ( retVal.isValidInt() ) { fetchProducts( ...
aluis.rcastro's user avatar
3 votes
2 answers
149 views

I have the following vector. Vector_1 <- c(0.1, 0.9, 0.5, (1 / 3), 0.5344) I want to multiply each element of this vector by the same number such that each number in the resulting vector is an ...
David Moore's user avatar
  • 1,026
-1 votes
1 answer
207 views

I need to convert floats to unsigned integers for a project I'm working on — similar to the basic float-to-int cast, but with an unsigned int as output, returning zero for floats that are negative. I ...
Coarse Rosinflower's user avatar
2 votes
3 answers
120 views

Context: I want to verify the fact that under 32-bits, Ox8000 0000 - 1 = Ox7FFF FFFF, so if both of them are interpreted as signed integers, the sign will change from negative to positive. Here goes ...
Ning's user avatar
  • 23
-1 votes
2 answers
150 views

im trying to get a powershell script to query display EDID info and put it into a reg key. when trying to add the key, it says its not found, but the reg key tree exists. it turns out that all the ...
shoober420's user avatar
3 votes
2 answers
160 views

CPython implements arbitrary-precision integers as PyLongObject, which extends PyObject. On 64-bit platforms they take at least 28 bytes, which is quite memory intensive. Also well-known is that it ...
qwr's user avatar
  • 11.6k
-2 votes
3 answers
285 views

Let there be integer n. Count how many numbers there are from 1 to n that has the sum of divisors being a prime number. Example: Input: 10 Output: 3 Explanation: There are 3 numbers with the sum of ...
Nguyen Tran Tung's user avatar
-4 votes
1 answer
131 views

Hello I just have a question about int function. It convert data(for example, string) to int data. My question is how this function works like this? I tried to implement int function myself without ...
eunsang's user avatar
  • 23
1 vote
1 answer
115 views

#include <stdio.h> int main() { int i, count; printf("Enter an integer: "); scanf("%d", &count); for (i = 1; i <= count; i++) { printf(&...
Everyday Learner's user avatar
1 vote
3 answers
209 views

I know that signed int overflow is undefined in C. I understood this as the resulting number is not predictable, but it is still a number. However, this code does not behave like the result of an ...
Pavel's user avatar
  • 29
0 votes
0 answers
49 views

The following function public int GetNumber() { int num = (condition1 ? 3 : (condition2 ? 1 : 2)); int num2 = (condition3 ? 6 : (condition4 ? 3 : 0)); return num + num2; } returns the ...
Blechle 's user avatar
1 vote
2 answers
118 views

Is there something in the C standard that implies only one representation for signed integers should be used? Specifically, does the standard prohibit using, for example, one's complement for int ...
Some Old Jaded Guy's user avatar
-7 votes
3 answers
93 views

I think my question is a little confusing, so here is what I am trying to do: I would like to take my inputted number, 683, and I would like my program to compare it with this given number, 836. I am ...
Huzaifa Siddiqui's user avatar
-1 votes
1 answer
57 views

I have an if statement where a variable smallest is being compared to a variable num (integer). That if statement is in a loop that goes through an array of integers. smallest starts out as None, my ...
Lisa's user avatar
  • 9
1 vote
0 answers
75 views

I'm writing code to group points around each point in a curve into concentric regions. Then I find the geometric median of each region as way of determining its "shape". The point indices ...
lilbumblingbee's user avatar
4 votes
2 answers
268 views

This came up in a C++ program I am writing for iterating over a loop, where it was pointed out that the for loop condition a * b > c could overflow. I am rusty with integer math but I think, ...
qwr's user avatar
  • 11.6k
0 votes
1 answer
29 views

Here is my implementation of fib on LLVM-IR, everything work fine under i64 limit, but above that, it can't printf the correct result, even with attempt to truncate i128 into 2 halves of i64 : define ...
user avatar
0 votes
0 answers
85 views

I am taking Google's Kotlin Basics course for Android development. I am now at a exercise that wants me to create a function that calculates the sum of whatever number two variables hold (there are ...
Kevin Haandrikman's user avatar
4 votes
1 answer
270 views

I am writing some DSP code that performs wavefolding distortion on an input signal. This code applies amplitude gain (multiplies input by a gain value) then wave folds the input such that the final ...
Emmett Palaima's user avatar
0 votes
2 answers
137 views

I was trying to do one coding questions solve, that says: Write an alternate version of squeeze(s1, s2) which deletes each character in s1 which matches any character in the string s2.". Well i ...
Haru Hoshizora's user avatar
3 votes
3 answers
169 views

I'm making my way through Learn C the Hard Way, in which the author often asks students to intentionally "break" the examples to learn debugging. In Exercise 11, it's suggested to attempt to ...
asdfadf's user avatar
  • 133
-1 votes
1 answer
77 views

I'm trying to convert a string example "12 34 56" into a vector of integers using Rust. I tried using .chunks() and a few other things the code I used works as expected for "123456"...
user28948807's user avatar
1 vote
1 answer
97 views

I'm currently learning C while following along with The C Book and one of the excercises is to write a program that lets the user input a number, which the program will spit back afterwards. While ...
Markix's user avatar
  • 23
3 votes
2 answers
227 views

I'm trying to make a simple Fibonacci calculator, but bitints max bit number of 65535 is too small. Is there any way to get a bigger integer? typedef unsigned _BitInt(65535) u65535; int main(void) { ...
Ibolya Vojtek's user avatar
0 votes
1 answer
54 views

In .NET, assuming that a decimal is not so large that it cannot be represented (or cause an overflow), will a decimal that is equal to an int always cast to the int that it is equal to ? Same question ...
H2ONaCl's user avatar
  • 11.5k
0 votes
2 answers
76 views

I have a Pandas dataframe that has been created by importing from an Excel spreadsheet. When using the .dtypes method, the column appears to be of data type object. However, within the single column, ...
user1718097's user avatar
  • 4,332
1 vote
1 answer
117 views

I was wondering what the difference is between converting an integer to a double using double versus multiplying the integer by 1.0 int a = 4 int b = 3 double c = 1.0 * a / b double d = (double) a / ...
NoxAtra's user avatar
  • 13

1
2 3 4 5
466