Skip to main content
1 vote
2 answers
148 views

How can I convert a char into an int within the range of 0 and 255 in C++

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
  • 61
3 votes
2 answers
216 views

C treating variable declared to be a double as an int

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
172 views

integer comparision; difference in behavior between Clang and GCC 12

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.3k
3 votes
1 answer
85 views

How does Rust lexer handle the integer literal?

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
121 views

Conversion to int with Unicode strings

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
-5 votes
2 answers
118 views

In this python script that checks for integer values, why is one entry not removed? It's the letter x. Works for every other line [closed]

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
61 views

Sum of integer data and numeric data is unexpected numeric value, R [duplicate]

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
0 votes
2 answers
114 views

No output from Java program – no errors shown [closed]

I wrote Java code, which I took as a challenge for 30 days, but it is giving an error. I am trying to print the nth prime number, but it is not giving any output public class Practice{ ...
Ramya Bolla's user avatar
5 votes
5 answers
415 views

Why Zero has no decimal integer spelling in C?

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.7k
1 vote
1 answer
122 views

How does typecasting between different sized integers work in C++?

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
215 views

How to get integer unix timestamps in python? Not casting float to integer

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
31 views

How should I perform an elementwise cast of an OpenCL C vector value?

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
  • 137k
2 votes
2 answers
117 views

Convert String input to int array in Java

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
59 views

Numpy array from the image is not squaring right

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
86 views

Separate the integer part from the decimal part of a real number entered from the keyboard in Java

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

15 30 50 per page
1
2 3 4 5
1552