Programming :: Convert Gigabyte To Byte?
Nov 24, 2010
I'm learning C and trying to write a program to convert gigabyte into byte. It will take 50% of the value given and then convert that value into byte. But the problem is the output goes into minus / negative value. Like, if I enter 22, I get output: -2147483648.
Code:
#include <stdio.h>
#include <math.h>
main (int argc, char* argv[])
{
[Code]....
View 5 Replies
ADVERTISEMENT
Oct 26, 2010
I need to convert an integer to a byte array of size 2 and vice versa. The code shown below works well for positive values but not for negative values. Also, using an array of size four makes the conversion works. However, I am limited to an array of size 2.
View 5 Replies
View Related
Jul 6, 2011
I got across a peculiar problem with memcpy.History:writing a code which do flash/Read functionality for SPI Parts.
Implementation:
1.memory map the Flash chip registers to userspace. - fine
2.Issue block read command
3.Just print the data I got, using the memory mapped address - fine I got the correct data.
4.Copy the data to a local buffer from memory mapped address using memcpy - FAIL
UPDATE:
on SUSE 11.3 -32 bit the above code worked perfectly, but on SUSE 11.4 - 64bit , Ubantu, Fedora it failed.
I am using gcc compiler obviously. I am using i386/x86_64 OS. Processor: Intel core 2 duo, SNB after step 4 , when I dump the data from local buffer every thing is FF.But step 4, if i implement byte by byte copy using assignment operator, it worked.is there any known bug with memcpy? am I missing anything?
View 7 Replies
View Related
Jul 10, 2011
As 2.17
I want to code this:
and byte[45],03
In words, AND the byte at memory location 45 with immediate value 03. As reports "Ambiguous operand size for and". How could I code the instruction such that as understands my intention?
john: .byte 45
and byte[john],03
gives the same error.
View 8 Replies
View Related
Jun 11, 2010
E.g. 98 is represented as 1100010 (number of valid bits is 7)
What is the formula to calculate the number of valid bits in a byte ?
View 14 Replies
View Related
Aug 12, 2010
I'm trying to write an extension to PHP which means coding in C. I'm really really rusty at C coding and was never very good at it.
Can anyone propose an efficient, safe, and [hopefully] future-proof way of reversing a double? Keep in mind that it should work on as many systems as possible and on 32- and 64-bit systems (and on ???-bit systems in the future?). Will the size of a 'double' ever change or will it always be 8 bytes?
I've tried this and it doesn't work...the compiler complains about "invalid operands to binary" because I'm trying bitwise shiftw on a non-integer.
Code:
x = (x>>56) |
((x<<40) & 0x00FF000000000000) |
((x<<24) & 0x0000FF0000000000) |
((x<<8) & 0x000000FF00000000) |
[Code]....
View 3 Replies
View Related
Jun 16, 2010
I am trying to learn assembly using nasm as assembler. I did not found example related to string operation. I had following example code,
global asm_strlen
section .data
section .bss
section .text
[code].....
my problem is at highlighted line, I am not getting how to copy a byte into 4 byte reg. rather what is syntax of mov instruction to mov byte to WORD DWORD etc.
View 3 Replies
View Related
Jan 11, 2013
Assuming there are two list objects a1, a2.
a1 = ['
']
a2 =['hi
']
len() built-in function gives total number of elements in the list object.
len(a1) gives 1. len(a2) gives 1 also.
Code: Select all$ python
Python 2.7.3 (default, SepĀ 9 2012, 17:41:34)
[GCC 4.7.1] on linux2
[Code]......
I thought there exists a built-in function that gives total size of a list object in byte. So using the function produces 1 for a1, 3 for a2. I haven't found such function or module yet.
View 3 Replies
View Related
Dec 13, 2009
I wrote a serial port communication program to access a equipment.
int main(void)
{
int fd = 0;
int nread = 0,i = 0,nwrite = 0, tmpread = 0, m = 0, n = 0 ;
[code]....
View 2 Replies
View Related
Mar 26, 2011
Do I have the convert the int to a string using stringstream then convert the string to a char? or is there a more direct way?Also is there a way to tell the length of a int?
View 5 Replies
View Related
Apr 26, 2011
I want to load data into mysql database,I am having a xls file want to convert it into csv file to do it.I am running the script on apache server,was able to convert and I could see the output file,when I execute the php script in command line,but when I run it on the browser the file is not saved..??? .Whether something has to be configured on apache
View 1 Replies
View Related
Apr 6, 2010
I have an existing line of code from a P2 script that I cannot find a solution to converting to P3:
Code:
for i, x in map(None, list1, list2):
I have found the information about converting the simple case:
map(None,x) becomes list(x)
But my googling was unable to find a solution when more than one iterable exists.
View 2 Replies
View Related
Jul 6, 2010
Iam trying to check a value less than or equals 0.The value iam getting is after doing grep a file . but its throwing error .
Code:
When i execute this it throws
Code:
View 8 Replies
View Related
Nov 30, 2010
I am trying to write a kernel module which is the combination of the usb driver and a network driver, now whenever the data is recieved by the usb driver it will be in struct urb, but the data that is required by the net driver is sk_buff, now how do i convert a urb to sk_buff, i found something similar is being done in the phonet protocol, but i couldnt understand, howexactly this is being done. Can someone explain this code.
drivers/net/usb/cdc-phonet.c
Code:
static void rx_complete(struct urb *req)
{
struct net_device *dev = req->context;
struct usbpn_dev *pnd = netdev_priv(dev);
[Code]....
View 1 Replies
View Related
Jul 27, 2010
I have the source code for the dll file, and I want to convert it to .so file.the dll file has declared some functions like this in the .c file
declspec (dllexport) etc.
I want to use this program in linux(open suse). How to do it? Is it through Wine? Then how to do it exactly.
View 1 Replies
View Related
May 9, 2010
I've searched around and can't find out how to convert a string ( like "12345" ) into an int array ( x[ 5 ] = { 1, 2, 3, 4, 5 } ; ).
View 4 Replies
View Related
Jan 14, 2010
I wrote a bash script a few months ago and now I want to convert it to a C program. However, i used awk a lot in my script, and I don't know what to use in place of awk. The awk calls are simple, like string splitting and math, but I don't know of any replacement for the string splitting function. Are there any C libraries that include some sort of string splitting function?
View 4 Replies
View Related
Jun 20, 2011
I need to convert some .flac files into .mp3.
I found this script:
#!/bin/bash
FLAC=$1
MP3="${FLAC%.flac}.mp3"
[ -r "$FLAC" ] || { echo can not read file "$FLAC" >&1 ; exit 1 ; } ;
metaflac --export-tags-to=- "$FLAC" | sed 's/=(.*)/="1"/' >tmp.tmp
[Code].....
And I need it to run it from outside of a directory for several directories.
I need to run it from /dir for /dir/dire*
View 4 Replies
View Related
Jan 1, 2011
Im new to linux Iam pursuing bachelors in computer science engineering.... my final year project is to develop a "html to pdf converter using linux"... i have some basic knowledge of commands used in unix
1) Where can i get the basic idea about the existing converters... their pros and cons...
.... programming...
2) Any kind of material or source where i can get basic idea of programming used for converting html pages that are linked into a single pdf..
View 1 Replies
View Related
Aug 10, 2009
I bet this is a Perl one-liner (or very simple python script).I have a tab separated files in which each row looks like:Unique_Eight_Character_Sequence [3 tabs] data1~moredata1~moredata1 [3 tabs] data2~ moredata2~ moredata2 ... dataN~.The output file should have each column converted into a row (with the unique character sequence copied in for the first column), and then each "~" replaced by a comma.
View 14 Replies
View Related
Jun 6, 2011
How does one convert from DD/MM/YYYY to YYYYMMDD?
Code:
06/06/2011
06/06/2011
to
Code:
20110606
20110606
View 6 Replies
View Related
Jul 2, 2010
convert string to long ?
View 4 Replies
View Related
Dec 16, 2010
i was able to use XGetImage to get an image from desktop on my Linux, not the problem is that, can i use this output XImage and convert it to png? or even save this XImage to file and load it to XImage again later?
View 3 Replies
View Related
Apr 5, 2010
Someone know how i can convert from hex string to double in c/c++?? Example 40668472B020C49C is 180.139
reference page: http://babbage.cs.qc.edu/IEEE-754/64bit.html
View 10 Replies
View Related
Sep 19, 2010
main()
{
unsigned long long tsc_start, tsc_end;
tsc_start = get_tsc();
// execute some code
[code]....
View 1 Replies
View Related
Jul 15, 2010
Can anyone please suggest me how can we convert a wide char data in linux which is of 32 bit to a 16bit data. I have a file which has 16bit binary data? Could any one please give me ideas.
View 2 Replies
View Related
Feb 22, 2010
Code:
FILE_SIZE=`find /var/logs/ -type f -mtime +5 | wc -c`
im trying to convert FILE_SIZE into megabytes
[code]....
View 8 Replies
View Related
May 3, 2010
I'm trying to migrate my company server to linux, but i have a program that is designed in access what is the best way to move access tables to a mysql database so that i can program it in PHP?
View 3 Replies
View Related
Dec 14, 2010
I have a script that creates a textfile with ip addresses and ports, but the ports are in hex format so they need to be converted.
Currently I have this code:
Code:
I'd like to have the second column in decimal instead of hex, like this:
Code:
Is there any way to do that with awk, preferably in a oneliner? Would printf be an option?
View 11 Replies
View Related
Aug 18, 2010
i have problem in java. how to convert string array to character. e.g string a[]={"ab","abc","abd","ag"}; what will be the character array ?
View 3 Replies
View Related