Thanks for your code, I understood. In case I want to shift right, I write the code like that:
void shiftright(uint64_t *x)
{
int i;
unsigned char a,b=0;
b=x[0]&1;
for...
Type: Posts; User: lovesunset21
Thanks for your code, I understood. In case I want to shift right, I write the code like that:
void shiftright(uint64_t *x)
{
int i;
unsigned char a,b=0;
b=x[0]&1;
for...
What happen if I try the code like this? Is this correct?
void shiftleft(uint64_t *x)
{
unsigned char a,b=0;
int i;
b=x[19]& (1ULL<<63);
for (i=19;i>=0;i--){
a=x[i] &...
I am so sorry. I understand the rule to shift the bit to the left but I am really confused about the bit position. That's the reason why I do something stupid in my code. Let's me explain my code and...
In the shiftleft above, I do as followed:
1. shift 0 to left
2. check if the extreme left of 1 is 1, make a note.
3. shift 1 to left
4. if it is noted, set the extreme right of 0 to 1.
My problem is that when I tried shifleft function above. It seems right. I cannot find the wrong. Oh, I am going to be crazy
0000000000000000000000000000000000000000000000000000000000000001 ...
I rewrite my shiftleft and it seems correct. However, my program still works inaccurately.
void shiftleft(uint64_t *x)
{
unsigned char a,b=0;
int i;
//b=x[19]& (1ULL<<63);
for...
Amazing, why does it become all 0 after shiftleft? My shiftleft is wrong....
When I try to print the result of my shiftleft, it is for example:
before:
0110011001011101001100110010100100011010010101000100100111010000 ...
Thanks for your reply. Do you mean that I should turn off the 1279th bit?
Is there any problem in my leftshift? Please tell me.
Hi everyone,
I am trying to make a multiplication function in Binary Field with GF2m, f(x)=x^1279 + x^319 + x^127 + x^63 + 1.
Unfortunately, It does not work properly. I don't know why. Could...
Thanks so much cas
Hi everyone,
I try to work with an uint64_t as followed:
uint64_t a;
a=a| 1 <<63;
And it displays: "gf2m.c:71: warning: left shift count >= width of type". I don't know why. Please help...
Hi everyone,
I have two array of uint64_t values: a and b.
For example:
a={0x0B922A5894CCBA66ULL,0x1860C1FA43DFA1D6ULL,0x0A2C46E6F566C8BBULL}...
Thank you so much. I try and It works right now. It's great.
I have one more question. If I want to set bit at a position into a bit t. What should I do?
For example:
I have bit t.
In...
Thanks for your help. This is my code. I have an unsigned char array with 36 elements.
unsigned char s[36]
#define bit_at(a,i) !!(a[i / 8] >> (8 - (i % 8) - 1) & 1) //I copy this code from...
Hi everyone, I really need your help. How can I shift byte array as above. Thank you so much.
I don't know how to shift bit in a byte array with the first bit of a byte is the last bit of the previous as above. I have searched in Google.
Hi everyone, I need your help in shifting right the byte array. For example:
I have 3 bytes :
s1s2s3s4s5s6s7s8 s9s10s11s12s13s14s15s16 s17s18s19s20s21s22s23s24
---> 0s1s2s3s4s5s6s7...
What should we add into the code as Salem told? I am a dummy C. Therefore, I don't really understand his idea. Thanks
That's right. It should be 8, but it is alway 1. I am running it on Eclipse and Ubuntu
Yes, of course, I copy and paste
#include <stdio.h>
#include <stdlib.h>
typedef union t_byte_s
{ unsigned char MyByte;
unsigned char b0:1,
b1:1,
actually, when I try this:
It is 1, not 4. It should be 4, right?
Thanks so much. Can you explain the UNION keyword for me?
Thanks so much. But i don't really understand.
typedef struct
{
unsigned b1:1;
unsigned b2:1;
unsigned b3:1;
unsigned b4:1;
unsigned b5:1;
Thanks a lot. I have solved my problem. However, I still have question, please help me.
I am working with bit field. I have
typedef struct bytes{
unsigned char b8:1;
unsigned char...