All Questions
864 questions
0
votes
0
answers
69
views
How to merge 2 double arrays in c [closed]
I need to write a function that merges 2 double arrays together into a single array. How would I go about doing that?
EDIT:
I have 2 arrays that like this for example: double arr1[] = {3.75, 4, 2.6} ...
4
votes
1
answer
79
views
Given a double value x, why (signed long long)(x) != *(signed long long *)(&x)?
I wonder why the code below prints "wrong".
double x = 0x8000000000000000;
signed long long v1 = (signed long long)(x);
signed long long v2 = *(signed long long *)(&x);
printf( v1 == v2? ...
2
votes
1
answer
179
views
How can I handle floating-point precision in C when dealing with numbers very close to zero or other edge cases
I wrote a program in C that calculates three points based on three points that are given. So we are given points A, B, C and calculate points A', B', C'. Now there are three ways that these points ...
1
vote
0
answers
63
views
Datatype double declaration
I had a problem where, my answers were completely similar to the ones on the online judge, but they were deemed wrong.
I fixed it after a lot of tinkering, but I dont understand what is going on. ...
3
votes
1
answer
182
views
Why doesn't my manually entered double value match the expected value in C?
Question:
As a beginner, i am curious about memory architecture and how values get stored in memory, so I tried this code. Nothing else.
I'm trying to manually input byte values to create a specific ...
4
votes
1
answer
213
views
What happens when the integer value with more than 52-bit of mantissa is stored in the double data type?
#include <stdio.h>
int main() {
double a =92233720368547758071;
printf("value=%lf\n", a);
int i;
char *b = &a;
for (i = 0; i < 8; i++) {
printf("...
0
votes
0
answers
37
views
why does not insert the (temp->rlink)->llink (circular double linked list)
I want to know why (*dlist)->llink is not x(lptint error) when i write &(temp->rlink) instead &x
void lprintList(listPointer dlist) {
listPointer temp = (listPointer)malloc(sizeof(*...
1
vote
3
answers
94
views
Why is double printing the same value as float in C when they have different sizes?
I need to do calculations using π. When I checked precision of M_PI, it only printed 7 decimal digits. So I #defined my own MY_PI. But I am still facing the same problem. double should support 15-17 ...
-3
votes
1
answer
70
views
calloc only return arrays of size 8 [duplicate]
I'm trying to create arrays of doubles in C, such that every array has d doubles in it (the user inputs d). I tried using calloc to allocate the memory for each array:
double *vec;
vec = (double*) ...
0
votes
1
answer
81
views
data type is double, but below decimal point is calculated 0
Code explain: When I input three number, each number is saved in list[]. And then, it prints average and standard deviation.
Problem: standard_deviation value's below decimal point is calculated 0. I ...
7
votes
2
answers
216
views
strtod edge of denormals glitch
I have been looking at some code which had a weird optimisation fault and, in the process, stumbled upon a fault condition in strtod(), which has a different behaviour to strtof(), right on the edge ...
0
votes
2
answers
97
views
Printing doubles with large precision with printf, compiling with GCC
When printing with printf in a C program and specify how much characters I want after the decimal point with %.20f, it only gives me 15 characters and the rest are 0. I compile with GCC with the ...
1
vote
2
answers
58
views
Accessing Double Pointers in C
Assuming these random methods
void out_param_test(int *in, int **out)
{
int *temp = calloc(buffer_size, sizeof(int));
for (int i = 0; i < buffer_size; i++)
{
temp[i] = in[i]...
4
votes
2
answers
380
views
Is Using double variable type instead of float a bad habit [closed]
I have to code C for my college exams and I have practice of declaring double variables instead of float variables. Is it a bad habit? Can they deduct marks for it? (we never exceed the float limit)
I ...
1
vote
1
answer
59
views
How to unpack the TEDS ConRes type?
In a TEDS (Transducer Electronic Data Sheet) Template, there are two data types described as
ConRes.
"Constant resolution. This is a custom data type for compressed
floating point values that ...