Ariana
Really?
well why not
Anonymous
well why not
You forgot the ; code won't compile :(
Ariana
Ah you see I use a fuzzy compiler which is my imagination
Ariana
XD
Ariana
true
Ariana
why haven’t someone created one yet <looks at spaghetti code> nevermind
Anonymous
why haven’t someone created one yet <looks at spaghetti code> nevermind
Spaghetti code, it's been so long since I've seen one. Where did you see it?
Ariana
looks at hackathon codes 👀
Anonymous
Mmm... Everywhere?
gonna pay opthalmologist a visit; :(
Anonymous
why haven’t someone created one yet <looks at spaghetti code> nevermind
i see what were you talking here, the code looks delicious
Anonymous
I was given a question to find the sum of two numbers.the numbers can be int or float . But, I should print the exact answer. Ex: 5 2 Ans: 7 5.2 3 Ans: 8.2 not 8.200000 5.5 6.5 Ans: 12 not 12.0 I took both the numbers as float summed them up. K=(int)sum If(sum==k) printed("%d",k); This will satisfy integer answers like 12 but how to print the float numbers like 8.2 when I don't know how many numbers are there after decimal.
BinaryByter
cout will by default print the most resonable amount of precision
BinaryByter
use std::fixed for fine frained control
Anonymous
Idk c++
Anonymous
I was doing in c
Anonymous
use format specifier
Anonymous
Like?
Jussi
%f
Anonymous
printf("%3.3f\n", identifer);
Anonymous
%f would print 0s
Anonymous
We don't know whether it has 3 decimal portions or more or less
Anonymous
You wanted to print 4 digits so %.4f, but I don't know how many decimal places would be there in the sum
Anonymous
then leaving it to %f would be better
Anonymous
will print those extra 0s though
Anonymous
It would print extra 0s
Anonymous
Come on man it will not match the test cases
Anonymous
don't really know how to deal with it
Anonymous
/* gonna have a look at c programming language 2nd edition */
数学の恋人
A quick question, under what conditions might a += b; and a = a + b; give different results?
Anonymous
your os?
Anonymous
😂
Anonymous
A quick question, under what conditions might a += b; and a = a + b; give different results?
Never, but if you having product somewhere in between you may get different results
Anonymous
Ubuntu 19.04
Anonymous
Interesting
Anonymous
The c programming language book says %f won't print trailing zeros
Anonymous
Anonymous
When
it happens in a few cases, don't remember when
数学の恋人
Here's the C++ code
数学の恋人
When
and here's the output
Anonymous
a compound assignment expression v1 op= v2 is equivalent to v1 = v1 op v2 but v1 is evaluated only once edit: it's an equation but why do we call it an expression in programming?
Anonymous
but in v1 = v1 op v2; v1 is evaluated twice
Anonymous
so another increment
Anonymous
so many memories with it
klimi
Here's the C++ code
That's colorful
数学の恋人
That's colorful
that's dracula
Anonymous
that's dracula
isn't Dracula vs code theme?
klimi
that's dracula
i mean the whole setup
数学の恋人
数学の恋人
i mean the whole setup
Yeah it sure is
Anonymous
oh nice
klimi
arent you red?
Anonymous
klimi
Anonymous
okie
数学の恋人
klimi
Yes I am
oh nice
itsmanjeet
I don't know it possible or logical But can we done something to use a file as storage heap in c programs Like a file and all the variable and array etc stores in it In other words Using file as storage for variables and array for c program Like initializing a variable normally And it store automatically in file
BinaryByter
yes, its doable
BinaryByter
but its completely stupid, because file access is very slow and will damage the drive if you are using an SSD disk
BinaryByter
for how to do it look into mmap, std::allocator and fopen
BinaryByter
also, in order to be used, the data will have to be loaded from the file
BinaryByter
I have no idea about that
thats why I told you to read up on them
BinaryByter
also, if you plan on storing your variables into a file from ram, i'm going to disillusion you: it will only work with a few variable types