Anonymous
Size of a float...?
I am getting output for second printf as -1
Anonymous
Can anyone explain why?
Anonymous
??
Vikram
Ok
MᏫᎻᎯᎷᎷᎬᎠ
Can anyone explain second printf conditon?
is that float *fptr = fptr + 4?
Anonymous
No, its ftr++
Anonymous
Pf is printf
MᏫᎻᎯᎷᎷᎬᎠ
Anonymous
What's your explanation??
Talula
pF means PicoFarad
Anonymous
pF means PicoFarad
Kindly,Consider it as printf
MᏫᎻᎯᎷᎷᎬᎠ
I think i got it
Anonymous
I think i got it
Please explain it
MᏫᎻᎯᎷᎷᎬᎠ
and since my bad english i can't explain it lol
olli
What's your explanation??
float * fptr2 = fptr1++; is the same as float * fptr2 = fptr1; ++fptr1; So fptr1 points to fptr2 + 1 Therefore fptr2 - fptr1 equals -1
Anonymous
the distance between two pointers is (total bytes) / sizeof(the size of pointer type)
olli
I think it is right, can you elaborate a bit more??
What is unclear? the Post-increment? or the pointer subtraction?
MᏫᎻᎯᎷᎷᎬᎠ
yes
MᏫᎻᎯᎷᎷᎬᎠ
it must substract the content, not the pointers
MᏫᎻᎯᎷᎷᎬᎠ
that's wht printf do, right?
MᏫᎻᎯᎷᎷᎬᎠ
oh no
MᏫᎻᎯᎷᎷᎬᎠ
here is the pointer is -1
Anonymous
the result of subtraction is how much items between two pointers
olli
The pointer subtraction
As @Williamlili mentioned, the distance between those two pointers is sizeof(float), since fptr1 points to the next element. The result is therefore -1. (prior minus next, => fptr2 points to one element before) If you were to convert the pointer to char pointers prior to the subtraction you would notice a different result
MᏫᎻᎯᎷᎷᎬᎠ
but
MᏫᎻᎯᎷᎷᎬᎠ
you get -1 from substraction as a pointer
MᏫᎻᎯᎷᎷᎬᎠ
not as the content
olli
The pointer subtraction
I we might ask, what result did you expect?
Anonymous
1
olli
1
fptr2 points the last element in the array, right? fptr1 points the end of the array, right? So fptr2 is to the left of fptr1 and in this case the smaller address
MᏫᎻᎯᎷᎷᎬᎠ
the last printf means printf("%f", -1);
many
How to calm down when your colleague writes really bad code and claim that the responsibility is yours
MᏫᎻᎯᎷᎷᎬᎠ
right @ollirz ?
olli
right @ollirz ?
I don't think so, the difference between pointers can't be a floating point value.
Anonymous
Thanks a lot @ollirz olli
MᏫᎻᎯᎷᎷᎬᎠ
like
olli
Got it
Great! :)
MᏫᎻᎯᎷᎷᎬᎠ
&ptr = -1;
MᏫᎻᎯᎷᎷᎬᎠ
i know you can't do that..
olli
is there -1 address in the memory?
probably not. but, I would consider addresses to be unsigned, so -1 is likely (in 2's complement) to be a number with all the bits set and this address is fine
MᏫᎻᎯᎷᎷᎬᎠ
oooh
MᏫᎻᎯᎷᎷᎬᎠ
like
olli
But the different between pointers can is signed to determine whether it is smaller or larger
many
Using negative pointer must be careful, checking the boundary is a must
MᏫᎻᎯᎷᎷᎬᎠ
-1 = in binary == 11111110
olli
-1 = in binary == 11111110
that would be (in 2's complement) -2 You need to set all bits for -1
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
:D
olli
Consider e.g. std::vector 'size_type` is an unsigned integer but the difference_type is a signed integer
MᏫᎻᎯᎷᎷᎬᎠ
with 2's complement 11111111
so, it was printf("%f", 11111111)
MᏫᎻᎯᎷᎷᎬᎠ
i meant the address here
olli
so, it was printf("%f", 11111111)
But in this case you print 11111111 as floating point value, by promoting the literal
MᏫᎻᎯᎷᎷᎬᎠ
i'm not talking about literal
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
at least wht i meant
Alex
/get
MᏫᎻᎯᎷᎷᎬᎠ
anyway
MᏫᎻᎯᎷᎷᎬᎠ
forget it
Bader
i guess more like text editor, but ya know what I mean
klimi
XD
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
And u can customize ur fonts to whetever u wany lol
klimi
Add emojis
MᏫᎻᎯᎷᎷᎬᎠ
Bader
Equipped with lines
it is quite literally a developer intergrated INTO an enviroment
Joe
Hi Guys, does anyone have experience with GNUPLOT? My question is: can I plot a graph from my C++ Application without Gnuplot being installed? I need a solution where I just click an executable on a PC without any extra programs that opens a new window where you see the graph.. Thanks!
many
I have a number of API uri in my code, how to store them? Use a lot of #define? Use a 2d array?
Mr. COwO2 Preis