Sponsored Content
Full Discussion: Bitwise negation
Top Forums Shell Programming and Scripting Bitwise negation Post 302117987 by Perderabo on Thursday 17th of May 2007 01:57:20 PM
Old 05-17-2007
Quote:
Originally Posted by dLloydm
There is one more thing I would like to verify. The course has the following question:
What do you think is the output of the following piece of code?
((x = 2#1101 & 2#110))
((y = ~x))
print - $y

The answer given is 11, as in decimal eleven or 2#1011.
From what I understand I think the answer should be -5 as in -2#101.
You are correct:
$ ((x = 2#1101 & 2#110))
$ ((y = ~x))
$ print - $y
-5
$
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

bitwise operators

can anybody write a program to divide a number by another number using bitwise operators (9 Replies)
Discussion started by: areef4u
9 Replies

2. Shell Programming and Scripting

negation in find path

Guys, Pl suggest me how to ignore a path in find command... I am aware of using "!" for other option... but how can i use it like this exampl... I want to search something for in / but not in Pl help. Thanks.. (2 Replies)
Discussion started by: clx
2 Replies

3. Programming

bitwise and if

Hi Suppose we have these code lines: #define _IN_USE 0x001 /* set when process slot is in use */ #define _EXITING 0x002 /* set when exit is expected */ #define _REFRESHING 0x004 ... 1 main () { 2 3 unsigned r_flags =_REFRESHING; 4 5 if (r_flag &... (3 Replies)
Discussion started by: Puntino
3 Replies

4. Shell Programming and Scripting

if statement negation

Hi all, I've been searching the internet and can't find an answer to this. Im trying to figure out how to negate a whole expression befor an if. I'll explain below. Let's say x=0 y=1 ] (this is false) I would like to negate this whole boolean condition. To negate the above... (4 Replies)
Discussion started by: rethymno19
4 Replies

5. Homework & Coursework Questions

Negation

Hello, have anybody any idea, how to negate some expression? I have code that greps somethnig and I want filter from it some results...How to make it? IDontWantThisExpression=$1 grep 'some regex' | grep '$IDontWantThisExpression' testfile.txt Thanks for any advices. Faculty of... (2 Replies)
Discussion started by: Dworza
2 Replies

6. FAQ Submission Queue

Analysis in bitwise XOR

The purpose of this article is revealing the unrevealed parts of the bitwise XOR. As we aware, the truth table for the XOR operator is : A B A^B 0 0 0 0 1 1 1 0 1 1 1 0 For example , 1^2 will be calculated as given below: First the operands... (1 Reply)
Discussion started by: pandeesh
1 Replies

7. Shell Programming and Scripting

how to use bitwise or operator in /bin/sh

please any one can suggest me how to use bitesie || opearator to do this #initallize a=0 b=0 #condition if then a=0 else a=1 fi #bitwise or opeartion b = a || b Please view this code tag video for how to use code tags when posting code and data. (3 Replies)
Discussion started by: Palaniappan
3 Replies

8. Shell Programming and Scripting

Bitwise comparison of cols

Hello, I want to compute the bitwise number of matches in pairwise fashion for all columns. The problem is I have 18486955 rows and 750 columns. Please help with code, I believe this will take a lot of time, is there a way of tracking progress? Input Org1 Org2 Org3 A A T A ... (9 Replies)
Discussion started by: ritakadm
9 Replies

9. Shell Programming and Scripting

Negation in Bash Globbing

$ ls -1 a.1 b.1 x_a.1 x_b.1 $ ls -1 * b.1 x_a.1 x_b.1 $ ls -1 ** a.1 b.1 x_a.1 x_b.1The last result is not as expected. Why? Thanks. (2 Replies)
Discussion started by: carloszhang
2 Replies
Int32(3)							   OCaml library							  Int32(3)

NAME
Int32 - 32-bit integers. Module Module Int32 Documentation Module Int32 : sig end 32-bit integers. This module provides operations on the type int32 of signed 32-bit integers. Unlike the built-in int type, the type int32 is guaranteed to be exactly 32-bit wide on all platforms. All arithmetic operations over int32 are taken modulo 2^{32. Performance notice: values of type int32 occupy more memory space than values of type int , and arithmetic operations on int32 are gener- ally slower than those on int . Use int32 only when the application requires exact 32-bit arithmetic. val zero : int32 The 32-bit integer 0. val one : int32 The 32-bit integer 1. val minus_one : int32 The 32-bit integer -1. val neg : int32 -> int32 Unary negation. val add : int32 -> int32 -> int32 Addition. val sub : int32 -> int32 -> int32 Subtraction. val mul : int32 -> int32 -> int32 Multiplication. val div : int32 -> int32 -> int32 Integer division. Raise Division_by_zero if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for Pervasives.(/) . val rem : int32 -> int32 -> int32 Integer remainder. If y is not zero, the result of Int32.rem x y satisfies the following property: x = Int32.add (Int32.mul (Int32.div x y) y) (Int32.rem x y) . If y = 0 , Int32.rem x y raises Division_by_zero . val succ : int32 -> int32 Successor. Int32.succ x is Int32.add x Int32.one . val pred : int32 -> int32 Predecessor. Int32.pred x is Int32.sub x Int32.one . val abs : int32 -> int32 Return the absolute value of its argument. val max_int : int32 The greatest representable 32-bit integer, 2^{31 - 1. val min_int : int32 The smallest representable 32-bit integer, -2^{31. val logand : int32 -> int32 -> int32 Bitwise logical and. val logor : int32 -> int32 -> int32 Bitwise logical or. val logxor : int32 -> int32 -> int32 Bitwise logical exclusive or. val lognot : int32 -> int32 Bitwise logical negation val shift_left : int32 -> int -> int32 Int32.shift_left x y shifts x to the left by y bits. The result is unspecified if y < 0 or y >= 32 . val shift_right : int32 -> int -> int32 Int32.shift_right x y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= 32 . val shift_right_logical : int32 -> int -> int32 Int32.shift_right_logical x y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x . The result is unspecified if y < 0 or y >= 32 . val of_int : int -> int32 Convert the given integer (type int ) to a 32-bit integer (type int32 ). val to_int : int32 -> int Convert the given 32-bit integer (type int32 ) to an integer (type int ). On 32-bit platforms, the 32-bit integer is taken modulo 2^{31, i.e. the high-order bit is lost during the conversion. On 64-bit platforms, the conversion is exact. val of_float : float -> int32 Convert the given floating-point number to a 32-bit integer, discarding the fractional part (truncate towards 0). The result of the con- version is undefined if, after truncation, the number is outside the range [ Int32.min_int , Int32.max_int ]. val to_float : int32 -> float Convert the given 32-bit integer to a floating-point number. val of_string : string -> int32 Convert the given string to a 32-bit integer. The string is read in decimal (by default) or in hexadecimal, octal or binary if the string begins with 0x , 0o or 0b respectively. Raise Failure int_of_string if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type int32 . val to_string : int32 -> string Return the string representation of its argument, in signed decimal. val bits_of_float : float -> int32 Return the internal representation of the given float according to the IEEE 754 floating-point ``single format'' bit layout. Bit 31 of the result represents the sign of the float; bits 30 to 23 represent the (biased) exponent; bits 22 to 0 represent the mantissa. val float_of_bits : int32 -> float Return the floating-point number whose internal representation, according to the IEEE 754 floating-point ``single format'' bit layout, is the given int32 . type t = int32 An alias for the type of 32-bit integers. val compare : t -> t -> int The comparison function for 32-bit integers, with the same specification as Pervasives.compare . Along with the type t , this function compare allows the module Int32 to be passed as argument to the functors Set.Make and Map.Make . OCamldoc 2014-06-09 Int32(3)
All times are GMT -4. The time now is 11:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy