Sponsored Content
Top Forums Programming Change Specific Value Of A Bit Post 302177554 by shamrock on Friday 21st of March 2008 01:00:38 PM
Old 03-21-2008
What platform are you on? All char type variables have a width of 8-bits so I'm not sure how you are getting a size of 32-bits for variables of char type.

Code:
#include <stdio.h>

int main(int argc, char **argv)
{
    unsigned long i, j;
    unsigned long var;    /* variable whose 15th bit you want to test */
    
    i = 0100000;          /* unsigned octal has 15th bit set to 1 and the rest are 0 */
    j = var & i;

    if (j == i)           /* if the 15th bit of var is set to 1 then j will equal i */
        printf("15th bit is set to 1\n");
    else                  /* if the 15th bit of var is set to 0 j will equal zero */
        printf("15th bit is set to 0\n");
}

 

10 More Discussions You Might Find Interesting

1. HP-UX

Change 32 bit to 64 bit Kernel

Hi, I'm using HPUX 11.11 on Vizualize B180L our productive machines have 64 bit kernel # file vmunix vmunix: ELF-64 executable object file - PA-RISC 2.0 (LP64) I got one test system, which should have the same HW (i was told it is the same HW) hpuxtest:/stand-->file... (3 Replies)
Discussion started by: funksen
3 Replies

2. Shell Programming and Scripting

change the format of a giving file ( a bit challenge) Thank you

Hi, I have a file like this: mgr1.dbf tool.dbf usr.dbf wow19.dbf wow2wow.dbf Can anyone help change the format after each line of reading to: mgr2.dbf # add 1 of *1.dbf tool2.dbf # if not a number exist, make it default to 2 usr2.dbf wow20.dbf # add 1 of *19.dbf wow3wow.dbf ... (5 Replies)
Discussion started by: netbanker
5 Replies

3. Shell Programming and Scripting

a bit tricky to change it multiple rows in one row and ...

Hi, I have an output file like: 1415971694 376 (12); 3434327831 376 (7); 2989082873 332 (3); 4075357577 332 (3); 1221064374 376 (2); 2372410470 376 (2); 2563564778 332 (2); 443221432 376 (1); ... (2 Replies)
Discussion started by: netbanker
2 Replies

4. Shell Programming and Scripting

How to change a specific character in a file

Hi, I have a data file with following structure: a|b|c|d|3|f1|f2|f3 a|b|c|d|5|f1|f2|f3|f4|f5 I want to change this data to: a|b|c|d|3|f1;f2;f3 a|b|c|d|5|f1;f2;f3;f4;f5 Data in column 5 tells the number of following fields. All fields delimiter after the 5th column needs to be... (6 Replies)
Discussion started by: sdubey
6 Replies

5. UNIX for Dummies Questions & Answers

Change Specific Line of a File

Hi everyone, I am attempting to do something that should be very simple. How do I replace a specific line of a file with different text, and then save that file to its original name? I believe I want to use the sed command with the c option, but I after trying many times, I can't get the right... (10 Replies)
Discussion started by: msb65
10 Replies

6. Shell Programming and Scripting

Change specific ip address in a file

I need to change a line from a xen cfg file using sed if it's possible. The original line is: vif = I want to change ONLY the IP address of the second part ==> ip=10.1.10.4 to another IP --> ip=192.222.11.6 The first one ip=123.456.789.123 keeps untouchable. My new line shoud... (9 Replies)
Discussion started by: iga3725
9 Replies

7. Shell Programming and Scripting

Change specific occurence with sed

Hello, I have this file. aaa port=1234 time bbb port=2233 name ccc port=4444 name Is there any way with sed to change only the occurence of "port" which comes after section to have as output : (12 Replies)
Discussion started by: rany1
12 Replies

8. Shell Programming and Scripting

change character(s) in specific column

Hi all! I need to change the final e every time when it is present in any word in column 1 to a; moreover, to change the final i again to a in any word in column 1, but just if word in column 2 begins with ha or si. Here below you can see a sample of my data: achwa ungeliachwa ungeli 1... (3 Replies)
Discussion started by: mjomba
3 Replies

9. Shell Programming and Scripting

how to change specific value for a entry in the file

Hello All, can someone please suggest me a one line command to change a specific value that is associated to an entry in the file. for example #more schedulefile quartz.job.manual.bonus.schedule=0 0 9 ? * * # it should be changed to #more schedulefile... (5 Replies)
Discussion started by: bobby320
5 Replies

10. Shell Programming and Scripting

Using awk to change a specific column and in a specific row

I am trying to change the number in bold to 2400 01,000300032,193631306,190619,0640,1,80,,2/ 02,193631306,000300032,1,190618,0640,CAD,2/ I'm not sure if sed or awk is the answer. I was going to use sed and do a character count up to that point, but that column directly before 0640 might... (8 Replies)
Discussion started by: juggernautjoee
8 Replies
Bit::Vector::Minimal(3pm)				User Contributed Perl Documentation				 Bit::Vector::Minimal(3pm)

NAME
Bit::Vector::Minimal - Object-oriented wrapper around vec() SYNOPSIS
use Bit::Vector::Minimal; my $vec = Bit::Vector->new(size => 8, width => 1, endianness => "little"); # These are the defaults $vec->set(1); # $vec's internal vector now looks like "00000010" $vec->get(3); # 0 DESCRIPTION
This is a much simplified, lightweight version of Bit::Vector, and wraps Perl's (sometimes confusing) "vec" function in an object-oriented abstraction. METHODS
new Creates a new bit vector. By default, this creates a one-byte vector with 8 one-bit "slots", with bit zero on the right of the bit pattern. These settings can be changed by passing parameters to the constructor: "size" will alter the size in bits of the vector; "width" will alter the width of the slots. The module will die if "width" is not an integer divisor of "size". "endianness" controls whether the zeroth place is on the right or the left of the bit vector. set(POS[, VALUE]) Sets the bit or slot at position "POS" to value "VALUE" or "all bits on" if "VALUE" is not given. get(POS) Returns the bit or slot at position "POS". display Display the vector. For debugging purposes. AUTHOR
Current maintainer: Tony Bowden Original author: Simon Cozens BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Bit-Vector-Minimal@rt.cpan.org SEE ALSO
Bit::Vector COPYRIGHT AND LICENSE
Copyright 2003, 2004 by Kasei This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2005-10-04 Bit::Vector::Minimal(3pm)
All times are GMT -4. The time now is 02:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy