Programming :: Calculate The Number Of - Necessary - Bits In A Byte ?

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


ADVERTISEMENT

Programming :: Awk - Calculate The Number Of Words Containing Letter E In A Textfile?

Oct 12, 2010

i need to calculate the number of words containing letter e in a textfile.

View 9 Replies View Related

Programming :: Memcpy Fails To Copy Data / But Byte By Byte Assignment Work

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

General :: Command To Return Number Of Bits (32 Or 64)?

Nov 7, 2010

What is a Linux command that I can run to programmatically return either 32 or 64 to indicate whether the processor is a 32 bit or 64 bit processor?

View 4 Replies View Related

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 View Related

Programming :: Byte At Memory Location 45 With Immediate Value 03

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

Programming :: C Function To Reverse The Byte Order In A Double?

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

Programming :: How To Convert Negative Integer To Byte Array?

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

Programming :: Traverse Byte Array In Assembly Using Nasm As Assembler?

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

Debian Programming :: How To Find Total Size Of A List Object In Byte

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

Programming :: Serial Port Communication Program Always Lose One Byte Data: 0x00?

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

Ubuntu :: 32 Bits Version Packages Work On The 64 Bits Edition?

Jun 19, 2010

when I reformat ubuntu, I use AptonCD to save packages and then restore them without downloading anything over again. what I want to know is: I have the 32 bits ubuntu installed and then I downloaded the 64 bits version. If i reformat to the 64 bits one, would the DVD saved aptoncd packages from the 32 bits work on the 64 bits installation?

View 4 Replies View Related

Programming :: Calculate Length Of My Array?

Jun 30, 2010

I want to calculate length of my array, say Unix here.

Code:
[linux1@HMLINUX1 abc]$ declare -a Unix=('Debian' 'Red Hat' 'Suse' 'Fedora');
[linux1@HMLINUX1 abc]$
[linux1@HMLINUX1 abc]$ echo ${#Unix[@]}
5

This should be ideally 4, but somehow it is showing as 5. However, when I am removing the space as RedHat instead of Red Hat, it is working perfectly.

Code:
[linux1@HMLINUX1 abc]$ declare -a Unix=('Debian' 'Redhat' 'Suse' 'Fedora');
[linux1@HMLINUX1 abc]$ echo ${#names[@]}
4

View 4 Replies View Related

Ubuntu :: 64 Bits Install 32 Bits Windows In VirtualBox?

May 18, 2011

I am wondering if I can install a 32 bits guest Windows XP in VirtualBox in my 64 bits Ubuntu Natty host? I need a 32 bits Windows to run some programs.

View 6 Replies View Related

General :: Upgrade 32 Bits Programs To 64 Bits On Opensuse 11.2

Jan 5, 2010

I'm quite new to linux and I recently (and courageously) upgraded the computer of my work from opensuse 11.0 32bits to opensuse 11.2 64bits.

Well, everything would be quite fine except that I still have some softwares 32 bits that have the 64 bits version available. I know that because, using YaST, I can see by the Installed software section that there are 'choices' of versions for some programs; these versions are 'i586' and 'x86_64', and many of them have the i586 version installed.

So, I wonder if there is some type of auto upgrade all programs which are i586 and have the matching x86_64 avaliable...

View 6 Replies View Related

Programming :: Calculate Data And Make It Into New Column Using Awk?

May 24, 2011

i've been using a awk script to calculate my data... i have 3 files:

file a1.txt:

2
3
4

[code]....

the results were (3.5, 6 and 3) which is pretty easy.. now i want to combine all this into 1 file and each have different columns and called it avg.txt which have something like this in the end:

3.5 6 3

View 1 Replies View Related

Programming :: Bash Calculate The Repeated Lines?

Jan 28, 2010

i have a sorted file with many repeated lines like this:

1ujw
1ujw
1ul1
1us7

[code].....

i need to calculated haw many times each line is repeated, for ex

1ujw 2
1ul1 1
1us7 5
etc.

View 5 Replies View Related

Programming :: Calculate Logarithm In Bash Script?

Dec 12, 2008

I want to calculate log in bash script. I searched but could not find any bash command to directly do it. I am also thinking to send the variable in C program, calculate in C and get the answer back in bash script.But I think it is a long process. as I have to do this

i) gcc -o log log.c

ii) ./log > log_result.txt

iii) then read the result from log_result.txt

View 5 Replies View Related

Programming :: Clock() - Calculate How Much Time Does My Program Run?

May 11, 2011

im trying to calculate how much time does my program run, use very simple script

clock_t end, start;
start= clock();
int i;
printf("initial %d
",(int)start);
[Code]....

but it outputs 0 all the time. cant figure out where could be the problem.

View 2 Replies View Related

Programming :: Calculate The Time Taken For A Sample Program To Run?

Apr 24, 2011

i have the example code below, i want to calculate the time taken for a sample program to run. but i keep getting undefined reference error.

#include <sys/time.h>
#include <iostream>
int main(int argc, char **argv) {
struct timeval startTime;
struct timeval endTime;

[Code]...

View 9 Replies View Related

Programming :: Calculate The Amount Of Data Had Been Download?

May 3, 2011

i'm trying to write a program with c socket programming,what i am trying to reach is a program which will calculate a computer's downloaded data from the internet,just to know how much he/she download?

View 1 Replies View Related

Programming :: Calculate How Many Nanosecond The Process Takes

Apr 10, 2011

ı need to calculate how many nanosecond the process takes . must give the same value every time (c++) ubuntu 10.10 my system information:

*-cpu
description: CPU
product: Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz
vendor: Intel Corp.
physical id: 400

[code]...

View 6 Replies View Related

Programming :: Calculate The Blade Offset In Python?

Dec 30, 2010

I'm using pyqt3 for my app and am lost on even how to attempt this task... On a vinyl cutter to have the blade pivot it must be offset from the center of the shaft it's on so say for example a .25mm offset would leave a .25mm unwanted vinyl attachment when the cutting is done. I somehow have to average or extrapolate that .25mm xy coordinate and add it to the hpgl plot file as a PUx,y; command? I have enclosed a simple sample file that has three images in it. In the corresponding hpgl file everything between the PU commands that are starting with PD are the code for that image (star for eg the pu to move to next image and then all PD for the next image and so on, so once the formula or procedure is figured out it can be applied to as many images there are in the file. Placing the new command at the head of each image PD group. Since there are absolute and relative cutters I enclosed the same exact plot for both types as the coordinates on relative can be negative numbers. Only PU and PD commands and a ";" as a command delimiter as sometimes many commands are on one line.The offset variable will come from a spinbox but .25 is good for an example.

View 14 Replies View Related

Programming :: Sudoku - Calculate The Correct Box For A Given Square?

Apr 8, 2011

Im doing a sudoku-solver as a school assigment in Java. It is supposed to solve both 6x6, 9x9 and 12x12 boards.Im pretty much done with my algorithm(brute force), but I'm having a hard time figuring out how to calculate the right Box for a Square. I found this snippet:

Code:

// calculate BoardPos for index, where index is 0..80
void loadBoardPosFromIndex(BoardPos &pos, int index) {
pos.index = index;

[code]...

This works on 9x9 boards, but I really dont get the math behind this, and how I can create a generic rule for both 6x6, 9x9 and 12x12 boards.

View 4 Replies View Related

Programming :: Write A Script That Will Calculate A Directory Size?

Jan 20, 2009

I'm trying to write a script that will calculate a directory size and if the size is greater than 4GB, it will send out an email. But I am getting the "integer operation expected" error when it tries to calculate the current disk size. Here's my script.

Code:

TO="user@email.com"
SUBJ="Ready for DVD burning on `hostname`"
MAIL="/bin/mail"

[code]....

View 1 Replies View Related

Programming :: Calculate Flash Memory End Address Of A Certain File?

Mar 9, 2011

how to calculate (if possible) the end address of an image file in a flash memory. I'm trying to create a checksum and checkheader function and the info that I got is the file's offset, how many sector it consumes and its size. I kinda need the end address, sad thing is, I don't know how to calculate it.test.img's start address is 0, the size is 0x20000 and consumes 3 sectors.

View 6 Replies View Related

Software :: Can Install 32 Bits On System 64 Bits

Jan 5, 2010

Can I install Linux 32 bits on system 64 bits?

For example if I have cpu 64 bits, can I install ubuntu 32 bits?

If yes, all drivers will befor 32 bits, right?

View 7 Replies View Related

Software :: Vmware 64 Bits On 32 Bits OS Host

Jun 9, 2010

I just create a vm image with 2 CPUs to be used on a one CPU machine. it works great. Now, i am thinking about creating a 64 bits Redhat VM image to be run on my 32 bits machine. Is that possible?

View 2 Replies View Related

Slackware :: Button Of Xchat On 13.1 In 64 Bits And 32 Bits

Jun 21, 2010

I notice this in all my machines (32bits and 64bits).

View 1 Replies View Related

Programming :: Calculate The Minutes Difference Between Two Dates Using The Function Mktime() On C++?

Jul 28, 2010

I'm trying to calculate the minutes difference between two dates using the function mktime() on c++. The dates will be passed to me as struct tm, and I will use this function many many times. The example below shows what I wanna do:

Code:

int main(int argc, char** argv) {
while (1) {
tm date2;
tm date1;

[code]...

I read the mktime() description on c++ reference, searched google... but there is no light

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved