Anonymous
is this wrong;-
Anonymous
char names[] = {'zero','one','two','three','four','five','six','seven','eight','nine'};
Anonymous
string names[] = {'zero','one','two','three','four','five','six','seven','eight','nine'};
☬ੴ Bassi
ii thought strings had to be in " "
Roxifλsz 🇱🇹
ii thought strings had to be in " "
Indeed they do, single quotes are for single characters
☬ੴ Bassi
Sometimes it's best to comment out the noise and focus on that little bit
☬ੴ Bassi
Like the first cout
samuel
Anyone here who can help.mee
samuel
I want a code for this pattern
samuel
samuel
Plz help me
Dima
@roxifas
Roxifλsz 🇱🇹
/ban
Roxifλsz 🇱🇹
@roxifas
You really could've done that yourself
☬ੴ Bassi
why did he get banned
Dima
why did he get banned
because read the rules
Vinícius
/get ide
Mar!o
I've created a little benchmark to benchmark the following: What is faster: Having one array of elements and passing around indices to elements. Like: std::vector<int> Iterating over it should be faster because the elements directly will be in the cache. VS std::vector<int*> For some reason the pointer variant was faster in lookups AND iterating over it!!! HOW??
Mar!o
I had many structs, some referred to element by indices: std::size_t nodeElem; and in the second version: int* nodeElemt; I just don't get it how pointers can be faster when iterating because the cache will be invalidated each time because the int s are somewhere random on the heap while with the first version they will be in cache.
Mar!o
I know pointers to vector elements are UB but I prevented reallocations
Mar!o
V01D
Okay, I am not getting this.. Goal: convert decimal to hex. Hex value is 0xA ~ Decimal: 10 The calculation is: 10 / 16 % 16 Result should be: 10? (Technically 0.something, but I need to extract the decimal value from the hex value.) I am getting 15 back (working with int's.) I can't use stdlib for this. (It is for a kernel)
V01D
Question is why do you do conversion exactly?
I need to print debugging data returned from the PIC for my kernel. Data is handled in hex for that. And I only have string and integer printing routines
V01D
Yeah
V01D
Language is C
Vlad
I think you can store char symbols[16] = "0123456789ABCDEF" and then do power of 16 based division
Vlad
And extract needed symbol given index
su
I used -O3
i'm not a Vanga, really
V01D
I think you can store char symbols[16] = "0123456789ABCDEF" and then do power of 16 based division
I am not getting any closer. I feel extremly awkward, because I should be able to do this. I don't understand why it isn't working. Do not mind bool use_y. The hex value is: 0xCA. After itoa the value is 202, which is correct, but when I enter the foreloop and perform the calculation, I get 7. Please give me a tip, not the answer. pastebin.com/evvXnwE3
V01D
I will try to make an enum with: decimal_num = hex_num . In the function I will check if the result of the division = the enum[resultofdiv] by looping through the enum. I just need to figure out why the equation doesn't work.
Vlad
Also strlen on _ulong64* is very suspicious
Vlad
And I don't know why do you pass pointer in the first place.
Vlad
V01D
Also strlen on _ulong64* is very suspicious
I needed a pointer because I was using it as an array.
V01D
I am also not 100% when to use pointers and when not to.
V01D
In this case it seems I forgot to take it out.
Vlad
I needed a pointer because I was using it as an array.
Isn't it a function that prints single value?
Vlad
And 8 bytes isn't that big of a deal to copy over
V01D
Isn't it a function that prints single value?
Yes. I tried looping through each character (0-9, A-F)
Vlad
Cause that's exactly what you need in this case
V01D
I have putc and putc_at, so yes.
V01D
So you are saying to take the each character in the hexvalue, convert it to a char, and call putc?
Navjot
Anyone help me plzz
Vlad
Yes via module of pow(16, i);
Begin from the biggest power
Navjot
How to convert 32 bit .exe into 64 🤔
Vlad
Begin from the biggest power
In 64 bits it's 8 hex symbols
Navjot
Recompile it
I did brother...but didn't took place..
Vlad
8 is 32 bits
Dima
How to convert 32 bit .exe into 64 🤔
install it twice so 32 * 2 = 64
V01D
So: for (int i....) { result = hex[i]; //Get char tostr(result); result = pow(16, i); putc(result); } Something like this?
Vlad
So: for (int i....) { result = hex[i]; //Get char tostr(result); result = pow(16, i); putc(result); } Something like this?
void foo(uint64_t arg) { char[16] hex = "0123456789ABCDEF"; char result; int values[16] = {0}; // each symbols value for(int i = 1; i < 16; ++i) { values[i-1] = arg % pow(16, i); arg -= values[i-1]; } }
Vlad
Kinda like this. Then print it in reverse order.
Vlad
putc(hex[values[i]]);
Vlad
Also I guess you could optimize away pow by bit shifting
V01D
What is going on in that for loop? Why values[i-1] twice, and why i-1 at all? why is the array accessed backwards?
Vlad
I guess this whole modulo thingy wouldn't work otherwise
V01D
Reversed is because I calculate smaller values first
I don't quite get that... How are you calculating smaller values by accessesing the backwards?
Vlad
But you've got to print it reversed