Home » All
Convert bytes to signed integer unsigned integer or float
How can I convert bytes to a signed or unsigned integer?
03/05/2012 - In Computer Programming - By kingk (art. no 28)How to convert bytes to signed integers, unsigned integers or float a C example
When you work with binary files, protocols or other binary data jobs you can have some problems to convert bytes to integers or float, here below there are some usefuls conversion functions from bytes to integers and bytes to float, those functions are for the Big Endian data format the 1st argument of each function is the most significant byte, to use the Little Endian format you can simply reverse the byte order.int bytes_to_signed_16_integer(unsigned char H, unsigned char L)
{
int value = ((H * 256) + L);
if ( value > 32767 )
value = ( value - 65536 );
return value;
}
int bytes_to_unsigned_16_integer(unsigned char H, unsigned char L)
{
int value = ((H * 256) + L);
return value;
}
int bytes_to_unsigned_32_integer(unsigned char HH, unsigned char HL, unsigned char LH, unsigned char LL){
int value = (HH*16777216) + (HL*65536) + (LH*256) + (LL);
return value;
}
unsigned int bytes_to_signed_32_integer(unsigned char HH, unsigned char HL, unsigned char LH, unsigned char LL){
unsigned int value = ((HH*16777216) + (HL*65536) + (LH*256) + (LL));
if ( value > 2147483647 )
value = ( value - 4294967295 - 1 );
return value;
}
float bytes_to_float(unsigned char HH, unsigned char HL, unsigned char LH, unsigned char LL){
float value = 0;
char data[4];
data[0] = LL;
data[1] = LH;
data[2] = HL;
data[3] = HH;
float *fptr = (float *)data;
value = *fptr;
return value;
}
{
int value = ((H * 256) + L);
if ( value > 32767 )
value = ( value - 65536 );
return value;
}
int bytes_to_unsigned_16_integer(unsigned char H, unsigned char L)
{
int value = ((H * 256) + L);
return value;
}
int bytes_to_unsigned_32_integer(unsigned char HH, unsigned char HL, unsigned char LH, unsigned char LL){
int value = (HH*16777216) + (HL*65536) + (LH*256) + (LL);
return value;
}
unsigned int bytes_to_signed_32_integer(unsigned char HH, unsigned char HL, unsigned char LH, unsigned char LL){
unsigned int value = ((HH*16777216) + (HL*65536) + (LH*256) + (LL));
if ( value > 2147483647 )
value = ( value - 4294967295 - 1 );
return value;
}
float bytes_to_float(unsigned char HH, unsigned char HL, unsigned char LH, unsigned char LL){
float value = 0;
char data[4];
data[0] = LL;
data[1] = LH;
data[2] = HL;
data[3] = HH;
float *fptr = (float *)data;
value = *fptr;
return value;
}
Read and Comment
Tags: Convert bytes to integer - How to convert bytes to float in C
Free Folder Sync Software in Java
Free Folder synchronization Software in Java
28/03/2012 - In Software - By kingk (art. no 27)Free folder synchronization software in Java for Windows, Linux and Mac
This application is a simple free synchronization folder software, you can configure it by setting a list of directory to synchronize in the list.txt configuration file that must be placed in the same directory of the "foldersync.jar" java binary file.To execute the application you need a Java software installed on your computer, you can run it with the standard command "java -jar foldersync.jar" by using the promtp/console or by clicking on the java file.
The software can be easily configured for automatic backups with Linux cron jobs or Windows Task Scheduler.
Example of list.txt configuration file
--------------------------------------
#SOURCE;DESTINATION
#
#This is a comment!
#
#Linux Example
/home/linux/syncme;/home/linux/sync
#Windows Example
c:\dir;C:\sync
--------------------------------------
The software will ovverride files in the destination directory (if present) in two cases:
1) The last modified data of the source is newer
2) The size of the source file is different from the destination file
Disclaimer: The operations of this freeware are not guaranteed.
Authors not warrant that the operation of the software will be free from interruptions or will be free of bugs.
In no case the author of the software or his subsidiaries: directors, officers, employees, affiliates or contributors be liable to the users for any damages consequential, incidental, indirect or any kind of special occurrence. Including, but not limited to, damages for loss of profits, interruption of business partnership, loss of business information and similar, or for any direct damage to business, to profits, whether or not foreseeable arising out of the use of inability to use the software or written materials annex, regardless basis of advanced claim (whether for breach of contract for negligence, for breach of rules on liability or any other violation of rule of law or otherwise) and even in cases where authors or one of its representative has been advised of the possibility of such damages.
Read and Comment
Free Folder Sync Software in JavaTags: Folder sync software Linux - Free folder sync software for MAC - Free folder sync software for Windows
Seo Tool Online - Custom Tips and Tricks for free
How to increase your website rank, Tips and Tricks!
14/03/2012 - In Webmaster - By kingk (art. no 26)How to increase website traffic for free, get tips and trick for free
A good SEO job is needed in every website to get good traffic from search engines, RocketMySeo.Com is a SEO company that offer a free online SEO tool.The seo tool can give to webmasters custom Tips related to a website, show what should be changed, what could be done, images, css and javascripts loading times and file sizes, the tool also give to each website a seo score, you can follow tips and improve your score by using the seo tool suggestions in your website.
The tool also shows the Google page rank, Alexa rank, website keywords, tag keywords and much more information about websites.
Try it, it's free follow this link: http://www.rocketmyseo.com/
Read and Comment
Tags: How to check google page tank
Bluehost review
Best hosting company Bluehost company review
22/02/2012 - In Webmaster - By kingk (art. no 25)Bluehost a top level hosting company
BlueHost is a web hosting company with good quality services at lowest price available in the market just 5.95$ / month!For just 5.95$ / month you can get this awesome hosting service with a very large variety of features to satisfy every needs you have.

Click here to register a Bluehost account!
Main Bluehost features
- Unlimited Domain Hosting
- Unlimited Hosting Space
- Unlimited GB File Transfer
- Unlimited E-mail Accounts
- Free Domain
- Secure Shell, SSL, FTP, Stats
- CGI, Ruby (RoR), Perl, PHP, MySQL
- $75 Free Google Credit
- 24/7 Phone, Chat & Email Support
+ Show the full features list
Bluehost test and considerations
The server is always fast and reliable, the CGI support on Bluehost is very good, you can run for example complex c++ cgi applications with no limitations, every CMS you want to install will run: the custom php.ini and .htaccess configuration are permitted.Some very good reasons to choose Bluehost:
BlueHost allow to buy additional domains for just 12$/each and add them in your main domain account, with the C-Panel you can assign each website url to point in a dedicated folder of your main account.
With Bluehost you can have more websites and pay almost the same as one.
For every domain you can add for free infinite subdomains, which are good to make a good SEO job.
Mail send rate Bluehost
Bluehost by default limit the Mail send rate to 150 mails / hour, this limit can be easily increased to 750 by asking them to raise it up.Negative points of Bluehost
Bluehost can disable the html page compression in basic hosting planes when the server load is too high to solve the problem you can choose the PRO package to have more dedicated CPU power, this is the unique limitation we found.
Click here to register a Bluehost account!
Disclosure: We are a professional review site that receives compensation from the companies whose products we review. We tested and reviewed the web hosting sites ranked here. We are independently owned and the opinions expressed here are our own.
Read and Comment
Tags: Best hosting plans - Bluehost send mail rate limit - Bluehost mail rate limit - Bluehost html gzip page compression limitations - Bluehost html gzip page compression limitations
Rgb Color Converter from 24 bit to 16 bit
Rgb 24bit to 16bit converter Android app
18/02/2012 - In Android - By kingk (art. no 24)Rgb color converter app from RGB 24 bit to RGB 16 bit
This Android App, converts the RGB color code from the standard 24bit color to the 16bit color.How to convert 24bit RGB color to 16Bit?
The 24 bit color code must be reduced to a 16 bit code, the most used format is the 16 bit 5,6,5 format.To perform a 24 bit color to a 16 bit (5,6,5) color conversion take most 5 significant bit of the R code, 6 most significant bit of G code and 5 most significant bit of the B code and store them in a 16 bit number.
How to use the application
To use this application "Rgb converter app" it, install the application in an Android 2.3 or compatible phone, open it and type the RGB color code you want to convert to 16 bit, click on the convert button.
The output format is the RGB 16bit 5,6,5.
Read and Comment
RGB Color Converter ToolTags: RGB 24bit to RGB 16bit conversion
Free Google Sitemap Generator XML
A free google sitemap generator xml software
18/02/2012 - In Software - By kingk (art. no 22)Free Google Sitemap Generator XML Software
The Free Google Sitemap XML generator software, is a Windows application that can scan websites and generate Google XML sitemaps files.How to generate google sitemaps xml files?
The application act like a spider, it scan the target website and it seek for valid urls of the same domain.To use it just type the website target url, and use the "Generate a new sitemap" button.
Read and Comment
FreeGoogleSitemapGeneratorXml
Tags: how to generate google xml sitemaps
RawDisk - Backup - low level format Disk Tool
RawDisk free low level disk backup and restore
18/02/2012 - In Software - By kingk (art. no 21)RawDisk - Backup and low level format Disk Tool
RawDisk is a free low level backup/restore tool, it can be also used to perform raw low level disk format.The 1st step for using it is to set the disk unit to backup, restore or format from the panel disk Settings.
Low level backup and restore functions
RawDisk, can backup and restore any disk unit of any partition format by using windows native low level kernel functions, the compress feature allow to generate compressed disk images.(Note: The unit to backup should not contain the running operative system)
The backup/restore functions are available from the Full Backup/Restore panel.
The selected unit can be saved into a disk image file, you can choose the full backup or the dump mode.
This feature allow for example the full backup of Xbox usb memory sticks, linux usb sticks etc.
The restore feature can also be used to create bootable USB stick with DOS, Linux or other OS.
How to backup and restore the MBR
The dump panel is for advanced users, it can be useful for example to make backups/restore of MBR disk sectors or others disk sections, in this section you have to use 512 multiple offsets.Low Level Disk format from Windows
The low level format format panel allow to perform low level disk format operations from windows, with just one click.Read and Comment
RawDisk
Tags: Free Low Level Disk utility - Free Low Level Disk format software - Free disk backup and restore tool - How to backup the MBR from windows - USB strick backup and restore tool
Space Shuttle Speed
How fast is a Space Shuttle?
In Miscellaneous - By kingk (art. no 20)Space Shuttle Top Speed
Which is the Space Shuttle top speed?The Space Shuttle top speed is about 17 500 mph, 28 168 km/h.
The Space Shuttle top speed is 38 341 time slower than the light speed which is 671 080 888 mph.
Read and Comment
C/C++ hex string to integer
How can i conver a Hex String to Integer in C++?
In Computer Programming - By kingk (art. no 19)Hex String to Integer C/C++
How to convert a C/C++ hex string to integer?There are no standard ansi functions to perform the data conversion from a hex string to integer.
The atoh function here listed can easily convert an Hex String to Integer.
int atoh(char * string, int size, bool reverse)
{
//By www.oldwildweb.com
unsigned int value = 0;
int char_val = 0;
int hchar_val = 1;
if (reverse == true)
for (int i = 0; i < size; i++)
{
if (string[i] == '0')
char_val = 0;
if (string[i] == '1')
char_val = 1;
if (string[i] == '2')
char_val = 2;
if (string[i] == '3')
char_val = 3;
if (string[i] == '4')
char_val = 4;
if (string[i] == '5')
char_val = 5;
if (string[i] == '6')
char_val = 6;
if (string[i] == '7')
char_val = 7;
if (string[i] == '8')
char_val = 8;
if (string[i] == '9')
char_val = 9;
if (string[i] == 'a' || string[i] == 'A' )
char_val = 10;
if (string[i] == 'b' || string[i] == 'B' )
char_val = 11;
if (string[i] == 'c' || string[i] == 'C' )
char_val = 12;
if (string[i] == 'd' || string[i] == 'D' )
char_val = 13;
if (string[i] == 'e' || string[i] == 'E' )
char_val = 14;
if (string[i] == 'f' || string[i] == 'F' )
char_val = 15;
value = value + (hchar_val*char_val);
hchar_val *= 16;
}
else
for (int i = size-1; i >= 0; i--)
{
if (string[i] == '0')
char_val = 0;
if (string[i] == '1')
char_val = 1;
if (string[i] == '2')
char_val = 2;
if (string[i] == '3')
char_val = 3;
if (string[i] == '4')
char_val = 4;
if (string[i] == '5')
char_val = 5;
if (string[i] == '6')
char_val = 6;
if (string[i] == '7')
char_val = 7;
if (string[i] == '8')
char_val = 8;
if (string[i] == '9')
char_val = 9;
if (string[i] == 'a' || string[i] == 'A' )
char_val = 10;
if (string[i] == 'b' || string[i] == 'B' )
char_val = 11;
if (string[i] == 'c' || string[i] == 'C' )
char_val = 12;
if (string[i] == 'd' || string[i] == 'D' )
char_val = 13;
if (string[i] == 'e' || string[i] == 'E' )
char_val = 14;
if (string[i] == 'f' || string[i] == 'F' )
char_val = 15;
value = value + (hchar_val*char_val);
hchar_val *= 16;
}
return value;
}
{
//By www.oldwildweb.com
unsigned int value = 0;
int char_val = 0;
int hchar_val = 1;
if (reverse == true)
for (int i = 0; i < size; i++)
{
if (string[i] == '0')
char_val = 0;
if (string[i] == '1')
char_val = 1;
if (string[i] == '2')
char_val = 2;
if (string[i] == '3')
char_val = 3;
if (string[i] == '4')
char_val = 4;
if (string[i] == '5')
char_val = 5;
if (string[i] == '6')
char_val = 6;
if (string[i] == '7')
char_val = 7;
if (string[i] == '8')
char_val = 8;
if (string[i] == '9')
char_val = 9;
if (string[i] == 'a' || string[i] == 'A' )
char_val = 10;
if (string[i] == 'b' || string[i] == 'B' )
char_val = 11;
if (string[i] == 'c' || string[i] == 'C' )
char_val = 12;
if (string[i] == 'd' || string[i] == 'D' )
char_val = 13;
if (string[i] == 'e' || string[i] == 'E' )
char_val = 14;
if (string[i] == 'f' || string[i] == 'F' )
char_val = 15;
value = value + (hchar_val*char_val);
hchar_val *= 16;
}
else
for (int i = size-1; i >= 0; i--)
{
if (string[i] == '0')
char_val = 0;
if (string[i] == '1')
char_val = 1;
if (string[i] == '2')
char_val = 2;
if (string[i] == '3')
char_val = 3;
if (string[i] == '4')
char_val = 4;
if (string[i] == '5')
char_val = 5;
if (string[i] == '6')
char_val = 6;
if (string[i] == '7')
char_val = 7;
if (string[i] == '8')
char_val = 8;
if (string[i] == '9')
char_val = 9;
if (string[i] == 'a' || string[i] == 'A' )
char_val = 10;
if (string[i] == 'b' || string[i] == 'B' )
char_val = 11;
if (string[i] == 'c' || string[i] == 'C' )
char_val = 12;
if (string[i] == 'd' || string[i] == 'D' )
char_val = 13;
if (string[i] == 'e' || string[i] == 'E' )
char_val = 14;
if (string[i] == 'f' || string[i] == 'F' )
char_val = 15;
value = value + (hchar_val*char_val);
hchar_val *= 16;
}
return value;
}
Usage example:
atoh("F0",2, true);
//Output: 240
Read and Comment
Tags: atoh function c cpp convert hex string to integer
grep recursive search
Linux grep recursive search
In Software - By kingk (art. no 18)Grep recursive search
How can I perform a recursive search with grep?Open a unix console and go into the folder where you want to search for with the cd command.
Now type
grep -R "string to search for" *
the -R argument means recursive search, the * is the file-name mask, you can for example search in all txt file with the mask *.txt.
Read and Comment
Bookmark this page