23,260 questions
-2
votes
1
answer
132
views
How can I parse ASCII byte input into integers for dates and readings in C? [closed]
I have a C function that receives data from an input source (e.g., a USB stick or sensor), where the input is ASCII characters representing numeric values. For example, I might receive:
"12/04/23&...
Best practices
0
votes
4
replies
29
views
Are there any convinient ways to facillate 64bit size allocatable arrays without changing the default integer in the IFX fortran compiler?
I have a Fortran code compiled with with the following flags:
-fc=ifx -O3 -r8 -i4 -fpe0 -no-ftz -fp-model=fast=2 -heap-arrays 0 -init=zero -init=arrays -I ./include/ -L ./lib/ -lfmetis -lmetis -o
...
0
votes
3
answers
109
views
If I subclass int, how to make arithmetic methods return the derived type?
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:
>&...
4
votes
1
answer
112
views
How to evaluate arithmetic expression in pseudo‑SQL style (Lua 5.1)
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 = {...
-1
votes
1
answer
118
views
Integer or Double vector? [duplicate]
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&...
Advice
1
vote
21
replies
409
views
Is there a reason why signed integer is used for the ssize_t?
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:
...
1
vote
2
answers
239
views
How to set int array pointer within for loop in c
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 ...
2
votes
1
answer
140
views
In python is there a way to get len with int data type and not and index-sized integer? [duplicate]
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 ...
4
votes
2
answers
182
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)'�';
...
3
votes
2
answers
239
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:
#...
4
votes
2
answers
197
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 ...
3
votes
1
answer
120
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 -> ...
5
votes
1
answer
141
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 '᪐᭒']
...
-4
votes
2
answers
128
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
...
0
votes
0
answers
62
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 ...