Home » U++ Library support » U++ Core » [SOLVED] Why long long int seems to be 32 bit longer?
Re: Why long long int seems to be 32 bit longer? [message #52152 is a reply to message #52148] |
Mon, 29 July 2019 20:24  |
 |
forlano
Messages: 1213 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Hello Tom and IƱaki,
thanks a lot for fixing my code. Only three terrible bugs in less than 10 row, almost a record! 
Now it works perfectly.
I hope to be able to save the long long int in a xml file and read it without loss of bits.
Best regards,
Luigi
PS: corrected code
#include <Core/Core.h>
using namespace Upp;
// set the kth bit
unsigned long long int setKthBit(unsigned long long int n, int k)
{
return ((1ULL << k) | n);
}
int getKthBit(unsigned long long int n, int k)
{
return (n & ( 1ULL << k )) >> k;
}
CONSOLE_APP_MAIN
{ unsigned long long int num = 0, n;
int k = 60;
n = setKthBit(num, k);
printf("%llu \n", n);
Cout()<<getKthBit(n,k);
}
[Updated on: Mon, 29 July 2019 20:35] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu Aug 21 05:25:45 CEST 2025
Total time taken to generate the page: 0.03287 seconds
|