Search Results

Search found 2467 results on 99 pages for 'bits'.

Page 10/99 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • What's the name for a bug that suddenly breaks things but has always been present?

    - by splattered bits
    We had a failure in our software today and after investigating discovered that the failure should have been occurring for weeks, but it waited until this morning to rear its ugly head. Is there an accepted name for such a bug that I can use when referring to it with other programmers? The closest I could find was a Schrödinbug, but I'm don't think it applies, since nobody was inspecting any code. The bug was just lying in wait.

    Read the article

  • What file format can represent an uncompressed raster image at 48 or 64 bits per pixel?

    - by finnw
    I am creating screenshots under Windows and using the LockBits function from GDI+ to extract the pixel data, which will then be written to a file. To maximise performance I am also: Using the same PixelFormat as the source bitmap, to avoid format conversion Using the ImageLockModeUserInputBuf flag to extract the pixel data into a pre-allocated buffer This pre-allocated buffer (pointed to by BitmapData::Scan0) is part of a memory-mapped file (to avoid copying the pixel data again.) I will also be writing the code that reads the file, so I can use (or invent) any format I wish. However I would prefer to use a well-known format that existing programs (ideally web browsers) are able to read, because that means I can visually confirm that the images are correct before writing the code for the other program (that reads the image.) I have implemented this successfully for the PixelFormat32bppRGB format, which matches the format of a 32bpp BMP file, so if I extract the pixel data directly into the memory-mapped BMP file and prefix it with a BMP header I get a valid BMP image file that can be opened in Paint and most browsers. Unfortunately one of the machines I am testing on returns pixels in PixelFormat64bppPARGB format (presumably this is influenced by the video adapter driver) and there is no corresponding BMP pixel format for this. Converting to a 16, 24 or 32bpp BMP format slows the program down considerably (as well as being lossy) so I am looking for a file format that can use this pixel format without conversion, so I can extract directly into the memory-mapped file as I have done with the 32bpp format. What raster image file formats support 48bpp and/or 64bpp?

    Read the article

  • Which C# / .NET free or standard bits and pieces do I need to make a simple Windows desktop app back

    - by jjujuma
    I'm coming from a Java / web background with no C# experience and I want to write a prototype C# / .NET desktop app to run against my existing DB2 database. The idea is that the prototype should use libraries and tools which are suitable for scaling up to full production and should be standard and free. Of the top of my head, the two biggest things I need are: an IDE a GUI toolkit / set of components a JDBC equivalent and/or possibly a full blown ORM system What are my options? Note I don't mind paying for full blown Visual Studio in the long run, but for now everything needs to be free, including the IDE.

    Read the article

  • Is there any sence in performing binary AND with a number where all bits are set to 1

    - by n535
    Greetings everybody. I have seen examples of such operations for so many times that i began to think that i am getting something wrong with binary arithmetics. Is there any sense to perform the following: byte value = someAnotherByteValue & 0xFF; I don't really understand this, because it does not change anything anyway. Thanks for help. P.S. I was trying to search for information both elsewhere and here, but unsuccessfully.

    Read the article

  • How to check code is compatible with Windows 7

    - by Julen
    Hello, We are developing using Visual C# 2008 Express a program based on WPF under Windows XP machines (32 bits). The thing is that we have tried to run the program in two Windows 7 machines, one is 32 bits Windows 7 and the other is 64 bits Windows 7. Under Windows XP everything is fine. In Windows 7 machine, it launches in the 32 bits version altough there is an error when running one functionality (it does not happen in XP). In W7 64 bits it even does not launch. Is this normal? Is not possible to run 32 bit programs under W7 64-bits,even if they execute slower?? How can we check the code is compatible with Windows 7? Thank you very much in advance. Julen.

    Read the article

  • How do I split up a long value (32 bits) into four char variables (8bits) using C?

    - by Jordan S
    I have a 32 bit long variable, CurrentPosition, that I want to split up into 4, 8bit characters. How would I do that most efficiently in C? I am working with an 8bit MCU, 8051 architectecture. unsigned long CurrentPosition = 7654321; unsigned char CP1 = 0; unsigned char CP2 = 0; unsigned char CP3 = 0; unsigned char CP4 = 0; // What do I do next? Should I just reference the starting address of CurrentPosition with a pointer and then add 8 two that address four times? It is little Endian. ALSO I want CurrentPosition to remain unchanged.

    Read the article

  • In maven2, how do I assemble bits and pieces of different modules to create final distributions?

    - by Carcassi
    I have four maven project: client api jar web service war ui jar web interface war The service war will need to be packaged to include the client api jar, together with javadocs (so that each version is distributed with a matching client and documentation). The web interface war will need the ui jar and all the dependencies (webstart/applet deployment). So I need a 5th project that does all the packaging. How to do this with ant or a script is perfectly clear to me, but not in maven. I tried the following: having the javadocs included as part of the war packaging: this requires the execution of the javadocs goal in project 1 before execution of package in project 2. Haven't found a way to bind plugins/goals across different projects. Using the assembly plugin in project2 had the same problem. create a fifth project and use the assembly plugin. Still the same problems as before, with the problem that since I need different pieces from each sub-project I do not understand how this can be done using the assembly. Is this too hard to do in maven, and should I just give up? Or I am looking at it wrong, in which case, how should I be looking at it? Thanks! Upon further reflection, here is a partial answer: Each project should build all its artifacts. This is done by having the plugins configured to run as per the prepare-resources and package phases. So, in my case, I prepare all that needs to be generated (jar, javadocs, xsd documentation, ...) as different artifacts so that a single "package" goal execution creates all. So, it's not "how project 2 forces project 1 to run different goals", but it's "make project 1 create all of its artifact as part as the normal lifecycle). This seems to simplify things.

    Read the article

  • I need to create a very large array of bits/boolean values. How would I do this in C/C++?

    - by Eddy
    Is it even possible to create an array of bits with more than 100000000 elements? If it is, how would I go about doing this? I know that for a char array I can do this: char* array; array = (char*)malloc(100000000 * sizeof(char)); If I was to declare the array by char array[100000000] then I would get a segmentation fault, since the maximum number of elements has been exceeded, which is why I use malloc. Is there something similar I can do for an array of bits?

    Read the article

  • How to optimize this simple function which translates input bits into words?

    - by psihodelia
    I have written a function which reads an input buffer of bytes and produces an output buffer of words where every word can be either 0x0081 for each ON bit of the input buffer or 0x007F for each OFF bit. The length of the input buffer is given. Both arrays have enough physical place. I also have about 2Kbyte free RAM which I can use for lookup tables or so. Now, I found that this function is my bottleneck in a real time application. It will be called very frequently. Can you please suggest a way how to optimize this function? I see one possibility could be to use only one buffer and do in-place substitution. void inline BitsToWords(int8 *pc_BufIn, int16 *pw_BufOut, int32 BufInLen) { int32 i,j,z=0; for(i=0; i<BufInLen; i++) { for(j=0; j<8; j++, z++) { pw_BufOut[z] = ( ((pc_BufIn[i] >> (7-j))&0x01) == 1? 0x0081: 0x007f ); } } } Please do not offer any compiler specific or CPU/Hardware specific optimization, because it is a multi-platform project.

    Read the article

  • How to pass multiple params to function in python?

    - by user1322731
    I am implementing 8bit adder in python. Here is the adder function definition: def add8(a0,a1,a2,a3,a4,a5,a6,a7,b0,b1,b2,b3,b4,b5,b6,b7,c0): All function parameters are boolean. I have implemented function that converts int into binary: def intTObin8(num): bits = [False]*8 i = 7 while num >= 1: if num % 2 == 1: bits[i] = True else: bits[i] = False i = i - 1 num /= 2 print bits return [bits[x] for x in range(0,8)] I want this function to return 8 bits. And to use this two functions as follows: add8(intTObin8(1),intTObin8(1),0) So the question is: How to pass 8 parameters using one function?

    Read the article

  • Higher order function « filter » in C++

    - by Red Hyena
    Hi all. I wanted to write a higher order function filter with C++. The code I have come up with so far is as follows: #include <iostream> #include <string> #include <functional> #include <algorithm> #include <vector> #include <list> #include <iterator> using namespace std; bool isOdd(int const i) { return i % 2 != 0; } template < template <class, class> class Container, class Predicate, class Allocator, class A > Container<A, Allocator> filter(Container<A, Allocator> const & container, Predicate const & pred) { Container<A, Allocator> filtered(container); container.erase(remove_if(filtered.begin(), filtered.end(), pred), filtered.end()); return filtered; } int main() { int const a[] = {23, 12, 78, 21, 97, 64}; vector<int const> const v(a, a + 6); vector<int const> const filtered = filter(v, isOdd); copy(filtered.begin(), filtered.end(), ostream_iterator<int const>(cout, " ")); } However on compiling this code, I get the following error messages that I am unable to understand and hence get rid of: /usr/include/c++/4.3/ext/new_allocator.h: In instantiation of ‘__gnu_cxx::new_allocator<const int>’: /usr/include/c++/4.3/bits/allocator.h:84: instantiated from ‘std::allocator<const int>’ /usr/include/c++/4.3/bits/stl_vector.h:75: instantiated from ‘std::_Vector_base<const int, std::allocator<const int> >’ /usr/include/c++/4.3/bits/stl_vector.h:176: instantiated from ‘std::vector<const int, std::allocator<const int> >’ Filter.cpp:29: instantiated from here /usr/include/c++/4.3/ext/new_allocator.h:82: error: ‘const _Tp* __gnu_cxx::new_allocator<_Tp>::address(const _Tp&) const [with _Tp = const int]’ cannot be overloaded /usr/include/c++/4.3/ext/new_allocator.h:79: error: with ‘_Tp* __gnu_cxx::new_allocator<_Tp>::address(_Tp&) const [with _Tp = const int]’ Filter.cpp: In function ‘Container<A, Allocator> filter(const Container<A, Allocator>&, const Predicate&) [with Container = std::vector, Predicate = bool ()(int), Allocator = std::allocator<const int>, A = const int]’: Filter.cpp:30: instantiated from here Filter.cpp:23: error: passing ‘const std::vector<const int, std::allocator<const int> >’ as ‘this’ argument of ‘__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> > std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, __gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >) [with _Tp = const int, _Alloc = std::allocator<const int>]’ discards qualifiers /usr/include/c++/4.3/bits/stl_algo.h: In function ‘_FIter std::remove_if(_FIter, _FIter, _Predicate) [with _FIter = __gnu_cxx::__normal_iterator<const int*, std::vector<const int, std::allocator<const int> > >, _Predicate = bool (*)(int)]’: Filter.cpp:23: instantiated from ‘Container<A, Allocator> filter(const Container<A, Allocator>&, const Predicate&) [with Container = std::vector, Predicate = bool ()(int), Allocator = std::allocator<const int>, A = const int]’ Filter.cpp:30: instantiated from here /usr/include/c++/4.3/bits/stl_algo.h:821: error: assignment of read-only location ‘__result.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = const int*, _Container = std::vector<const int, std::allocator<const int> >]()’ /usr/include/c++/4.3/ext/new_allocator.h: In member function ‘void __gnu_cxx::new_allocator<_Tp>::deallocate(_Tp*, size_t) [with _Tp = const int]’: /usr/include/c++/4.3/bits/stl_vector.h:150: instantiated from ‘void std::_Vector_base<_Tp, _Alloc>::_M_deallocate(_Tp*, size_t) [with _Tp = const int, _Alloc = std::allocator<const int>]’ /usr/include/c++/4.3/bits/stl_vector.h:136: instantiated from ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = const int, _Alloc = std::allocator<const int>]’ /usr/include/c++/4.3/bits/stl_vector.h:286: instantiated from ‘std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const _Alloc&) [with _InputIterator = const int*, _Tp = const int, _Alloc = std::allocator<const int>]’ Filter.cpp:29: instantiated from here /usr/include/c++/4.3/ext/new_allocator.h:98: error: invalid conversion from ‘const void*’ to ‘void*’ /usr/include/c++/4.3/ext/new_allocator.h:98: error: initializing argument 1 of ‘void operator delete(void*)’ /usr/include/c++/4.3/bits/stl_algobase.h: In function ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false, _II = const int*, _OI = const int*]’: /usr/include/c++/4.3/bits/stl_algobase.h:435: instantiated from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false, _II = __gnu_cxx::__normal_iterator<const int*, std::vector<const int, std::allocator<const int> > >, _OI = __gnu_cxx::__normal_iterator<const int*, std::vector<const int, std::allocator<const int> > >]’ /usr/include/c++/4.3/bits/stl_algobase.h:466: instantiated from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<const int*, std::vector<const int, std::allocator<const int> > >, _OI = __gnu_cxx::__normal_iterator<const int*, std::vector<const int, std::allocator<const int> > >]’ /usr/include/c++/4.3/bits/vector.tcc:136: instantiated from ‘__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> > std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, __gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >) [with _Tp = const int, _Alloc = std::allocator<const int>]’ Filter.cpp:23: instantiated from ‘Container<A, Allocator> filter(const Container<A, Allocator>&, const Predicate&) [with Container = std::vector, Predicate = bool ()(int), Allocator = std::allocator<const int>, A = const int]’ Filter.cpp:30: instantiated from here /usr/include/c++/4.3/bits/stl_algobase.h:396: error: no matching function for call to ‘std::__copy_move<false, true, std::random_access_iterator_tag>::__copy_m(const int*&, const int*&, const int*&)’ Please tell me what I am doing wrong here and what is the correct way to achieve the kind of higher order polymorphism I want. Thanks.

    Read the article

  • Downloading stuff from Oracle: an example

    - by user12587121
    Introduction Oracle has a lot of software on offer.  Components of the stack can evolve at different rates and different versions of the components may be in use at any given time.  All this means that even the process of downloading the bits you need can be somewhat daunting.  Here, by way of example, and hopefully to convince you that there is method in the downloading madness,  we describe how to go about downloading the bits for Oracle Identity Manager  (OIM) 11.1.1.5.Firstly, a couple of preliminary points: Folks with Oracle products already installed and looking for bug fixes, patch bundles or patch sets would go directly to the Oracle support website. This Oracle document is a comprehensive description of the Oracle FMW download process and the licensing that applies to downloaded software.   Downloading Oracle Identity Manager 11.1.1.5     To be sure we download the right versions, first locate the Certification Matrix for OIM 11.1.1.5: first go to the Fusion Certification Page then go to the “System Requirements and Supported Platforms for Oracle Identity and Access Management 11gR1” link. Let’s assume you have a 64 bit Linux Machine and an Oracle database already.  Then our  goal is to end up with a list of files like the following: jdk-6u29-linux-x64.bin                    (Java JDK)V26017-01.zip                             (the Repository Creation Utility to create the DB schemas)wls1035_generic.jar                       (the Weblogic Application Server)ofm_iam_generic_11.1.1.5.0_disk1_1of1.zip (the Identity Managament bits)ofm_soa_generic_11.1.1.5.0_disk1_1of2.zip (the SOA bits)ofm_soa_generic_11.1.1.5.0_disk1_2of2.zip jdevstudio11115install.exe                (optional: JDeveloper IDE)soa-jdev-extension.zip                    (optional: SOA extensions for JDeveloper) Downloading the bits 1.    Download the Java JDK, 64 bit version 1.6.0_24+.2.    Download the RCU: here you will see that the RCU is mentioned on the Identity Management home page but no link is provided.  Do not panic.  Due to the amount and turnover of software available only the latest versions are available for download from the main Oracle site.  Over time software gets moved on to the Oracle edelivery site and it is here that we find the RCU version we require: a.    Go to edelivery: https://edelivery.oracle.com b.    Choose Pack ‘ Oracle Fusion Middleware’ and ‘Linux x86-64’ c.    Click on ‘Oracle Fusion Middleware 11g Media Pack for Linux x86-64’ d.    Download: ‘Oracle Fusion Middleware Repository Creation Utility 11g (11.1.1.5.0) for Linux x86’ (V26017.zip) 3.    Download the Weblogic Application Server: WLS 10.3.54.    Download the Oracle Identity Manager bits: one point to clarify here is that currently  the Identity Management bits come in two trains, essentially one for the Directory Services piece and the other for the Access Management and Identity Management parts.  We need to be careful not to confuse the two, in particular to be clear which of the trains is being referred to by  the documentation: a.   So, with this in mind, go to ‘ Oracle Identity and Access Management (11.1.1.5.0)’ and download Disk1. 5.    Download the SOA bits: a.    Go to the edelivery area as for the RCU and download: i.    Oracle SOA Suite 11g Patch Set 4 (11.1.1.5.0) (Part 1 of 2) ii.    Oracle SOA Suite 11g Patch Set 4 (11.1.1.5.0) (Part 2 of 2) 6.    You will want to download some development tooling (for plugins or BPEL workflow development): a.    Download Jdeveloper 11.1.1.5 (11.1.1.6 may work but best to stick to the versions that correspond to the WLS version we are using) b.    Go to the site for  SOA tools and download the SOA Composite Editor 11.1.1.5 That’s it, you may proceed to the installation. 

    Read the article

  • Building the Bootsector of BIOSLOADER

    - by Kate Moss' Open Space
    Windows CE is a 32 bits OS since day one, so it makes sense tools shipped with PB, compiler, linker, assembler and etc, are for targeting to 32 bits system. But occasionally, if you are developing x86 based system and especially working on some boot code, such as boot sector of BIOSLOADER, that will be a problem. Normally, as PB provides the prebuilt boot sector image but if you ever need to rebuilt it, what should you do? You may say as it's an x86, perhaps you can use VS or Windows SDK to build it. But unfortunately, today's desktop Windows tool chains are also 32 or even 64 bits only, you need to find something older. VC++ 6.0, but how can you find one? This Website http://thestarman.pcministry.com/asm/masm.htm arranges some useful resources. Basically, you need 2 thing, the 16 bits MASM and 16 bits linker. Just make it even easier for you Download http://download.microsoft.com/download/vb60ent/Update/6/W9X2KXP/EN-US/vcpp5.exe for Assembler (MASM). Download http://download.microsoft.com/download/vc15/Update/1/WIN98/EN-US/Lnk563.exe for the Linker. And then just extract the archives and what you need is ml.exe, ml.err and link.exe

    Read the article

  • FlasCC requirements and limitations?

    - by Arthur Wulf White
    It is now available for download. It says you need twice* as many bits as I have. Why would you need more bits to compile code? Does that mean you need more bits to run flash games writtes with flasCC Did anyone try it out and happens to know the answers? http://gaming.adobe.com/technologies/flascc/ Minimum system requirements Flash Player 11 or higher Flex SDK 4.6 or higher Java Virtual Machine (64-bit) Windows Microsoft® Windows® 7 (64-bit edition) Cygwin (included) *This is meant as a joke. however I do own a 32-bit laptop and I am wondering why you need 64-bit. Afaik - You only need 64-bit if you want to run a system that has more than 4gigs of memory. Why would any flash game require more than 4 gigs of memory. The only system that is 64-bits and does not have 4gigs of memory that I can quickly recall is that hilarious Nintendo that came ages ago with a Motorola CPU.

    Read the article

  • how to record mic input and pipe the output to another program

    - by acrs
    Hi everyone Im trying to follow a tutorial on generating truly random bits How To Generate Truly Random Bits This is the command from the tutorial but it does not work rec -c 1 -d /dev/dsp -r 8000 -t wav -s w - | ./noise-filter >bits I know i can record my mic input using rec -c 1 no.wav this is the command i tried using rec -c 1 -r 8000 -t wav -s noise.wav | ./noise-filter >bits but i get root@xxc:~/cc# rec -c 1 -r 8000 -t wav -s noise.wav - | ./noise-filter >bits rec WARN formats: can't set sample rate 8000; using 48000 rec FAIL sox: Input files must have the same sample-rate I have complied noise-filter noise-filter I think the tutorial is using an older version of SOX and REC I'm using sox: SoX v14.3.2 on Ubuntu 12.04 server Can someone please help me ?

    Read the article

  • Can I animate render targets or the swap chain?

    - by Eric F.
    I want to animate some synthetic video bits to fullscreen w/o tearing. Can I set up D3D 9/10/11 in exclusive mode, and have it present a series of buffers that I'm writing to? I know how to copy system memory bits into a texture, then draw that texture as a fullscreen quad, but it seems like overkill. Why should I use the triangle rasterizer when I want to do something so simple? All I want to do is set up a long (4-8 buffer) swapchain and set the bits of the back buffer that is about to be displayed. Or, I want to allocate 4-8 RenderTargets, and on each frame, copy the bits from system memory to the RenderTarget, then set it as the next thing to display. I've never seen or heard about anybody doing this, but it seems so dead simple!

    Read the article

  • The sound freezes while listening to music

    - by Scott
    I have bought an sound card - Sound Blaster X-FI Surround 5.1 PRO and while I'm listening to the music, after few minutes or even hours (it does happends randomly) the sound dissapears and I have to go settings: Playing Devices - Advanced and switch the Default Format (sampling frequency) and switch from the `16-bits, 48000 Hz (DVD Quality) to any other from the list (16-bits, 96000 Hz or 24-bits, 48000 Hz or 24-bits 96000 Hz). I have been trying to set all of the above options, but for all of them the sound freezes after listening to music. It is getting annoying and I hope its the settings fault and not my sound card. I got my drivers installed from the attached CD and I'm running Windows 7 HP 64 bits. If anyone would try to help me, I would really appreciate this.

    Read the article

  • DrScheme versus mzscheme: treatment of definitions

    - by speciousfool
    One long term project I have is working through all the exercises of SICP. I noticed something a bit odd with the most recent exercise. I am testing a Huffman encoding tree. When I execute the following code in DrScheme I get the expected result: (a d a b b c a) However, if I execute this same code in mzscheme by calling (load "2.67.scm") or by running mzscheme -f 2.67.scm, it reports: symbols: expected symbols as arguments, given: (leaf D 1) My question is: why? Is it because mzscheme and drscheme use different rules for loading program definitions? The program code is below. ;; Define an encoding tree and a sample message ;; Use the decode procedure to decode the message, and give the result. (define (make-leaf symbol weight) (list 'leaf symbol weight)) (define (leaf? object) (eq? (car object) 'leaf)) (define (symbol-leaf x) (cadr x)) (define (weight-leaf x) (caddr x)) (define (make-code-tree left right) (list left right (append (symbols left) (symbols right)) (+ (weight left) (weight right)))) (define (left-branch tree) (car tree)) (define (right-branch tree) (cadr tree)) (define (symbols tree) (if (leaf? tree) (list (symbol-leaf tree)) (caddr tree))) (define (weight tree) (if (leaf? tree) (weight-leaf tree) (cadddr tree))) (define (decode bits tree) (define (decode-1 bits current-branch) (if (null? bits) '() (let ((next-branch (choose-branch (car bits) current-branch))) (if (leaf? next-branch) (cons (symbol-leaf next-branch) (decode-1 (cdr bits) tree)) (decode-1 (cdr bits) next-branch))))) (decode-1 bits tree)) (define (choose-branch bit branch) (cond ((= bit 0) (left-branch branch)) ((= bit 1) (right-branch branch)) (else (error "bad bit -- CHOOSE-BRANCH" bit)))) (define (test s-exp) (display s-exp) (newline)) (define sample-tree (make-code-tree (make-leaf 'A 4) (make-code-tree (make-leaf 'B 2) (make-code-tree (make-leaf 'D 1) (make-leaf 'C 1))))) (define sample-message '(0 1 1 0 0 1 0 1 0 1 1 1 0)) (test (decode sample-message sample-tree))

    Read the article

  • Number Algorithm

    - by James
    I've been struggling to wrap my head around this for some reason. I have 15 bits that represent a number. The bits must match a pattern. The pattern is defined in the way the bits start out: they are in the most flush-right representation of that pattern. So say the pattern is 1 4 1. The bits will be: 000000010111101 So the general rule is, take each number in the pattern, create that many bits (1, 4 or 1 in this case) and then have at least one space separating them. So if it's 1 2 6 1 (it will be random): 001011011111101 Starting with the flush-right version, I want to generate every single possible number that meets that pattern. The # of bits will be stored in a variable. So for a simple case, assume it's 5 bits and the initial bit pattern is: 00101. I want to generate: 00101 01001 01010 10001 10010 10100 I'm trying to do this in Objective-C, but anything resembling C would be fine. I just can't seem to come up with a good recursive algorithm for this. It makes sense in the above example, but when I start getting into 12431 and having to keep track of everything it breaks down.

    Read the article

  • Log 2 N generic comparison tree

    - by Morano88
    Hey! I'm working on an algorithm for Redundant Binary Representation (RBR) where every two bits represent a digit. I designed the comparator that takes 4 bits and gives out 2 bits. I want to make the comparison in log 2 n so If I have X and Y .. I compare every 2 bits of X with every 2 bits of Y. This is smooth if the number of bits of X or Y equals n where (n = 2^X) i.e n = 2,4,8,16,32,... etc. Like this : However, If my input let us say is 6 or 10 .. then it becomes not smooth and I have to take into account some odd situations like this : I have a shallow experience in algorithms .. is there a generic way to do it .. so at the end I get only 2 bits no matter what the input is ? I just need hints or pseudo-code. If my question is not appropriate here .. so feel free to flag it or tell me to remove it. I'm using VHDL by the way!

    Read the article

  • CSS horizontal scrolling box

    - by tony noriega
    im trying to create a horizontal scrolling box to create a "timeline" effect... but i cant seem to get it to scroll horizontally, versus the vertical scroll bar that shows up...thoughts? #container{ width:500px; height:250px; border:1px solid #cc61b8; overflow:auto; } .container-bits{ width:250px; height:498px; float:left; } <div id="container"> <div class="container-bits">Content Here</div> <div class="container-bits">Content Here</div> <div class="container-bits">Content Here</div> <div class="container-bits">Content Here</div> <div class="container-bits">Content Here</div> <div class="container-bits">Content Here</div> </div>

    Read the article

  • Find all ways to insert zeroes into a bit pattern

    - by James
    I've been struggling to wrap my head around this for some reason. I have 15 bits that represent a number. The bits must match a pattern. The pattern is defined in the way the bits start out: they are in the most flush-right representation of that pattern. So say the pattern is 1 4 1. The bits will be: 000000010111101 So the general rule is, take each number in the pattern, create that many bits (1, 4 or 1 in this case) and then have at least one space separating them. So if it's 1 2 6 1 (it will be random): 001011011111101 Starting with the flush-right version, I want to generate every single possible number that meets that pattern. The # of bits will be stored in a variable. So for a simple case, assume it's 5 bits and the initial bit pattern is: 00101. I want to generate: 00101 01001 01010 10001 10010 10100 I'm trying to do this in Objective-C, but anything resembling C would be fine. I just can't seem to come up with a good recursive algorithm for this. It makes sense in the above example, but when I start getting into 12431 and having to keep track of everything it breaks down.

    Read the article

  • Compilation problems with vector<auto_ptr<> >

    - by petersohn
    Consider the following code: #include <iostream> #include <memory> #include <vector> using namespace std; struct A { int a; A(int a_):a(a_) {} }; int main() { vector<auto_ptr<A> > as; for (int i = 0; i < 10; i++) { auto_ptr<A> a(new A(i)); as.push_back(a); } for (vector<auto_ptr<A> >::iterator it = as.begin(); it != as.end(); ++it) cout << (*it)->a << endl; } When trying to compile it, I get the following obscure compiler error from g++: g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/proba.d" -MT"src/proba.d" -o"src/proba.o" "../src/proba.cpp" /usr/include/c++/4.1.2/ext/new_allocator.h: In member function ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Tp*, const _Tp&) [with _Tp = std::auto_ptr<A>]’: /usr/include/c++/4.1.2/bits/stl_vector.h:606: instantiated from ‘void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = std::auto_ptr<A>, _Alloc = std::allocator<std::auto_ptr<A> >]’ ../src/proba.cpp:19: instantiated from here /usr/include/c++/4.1.2/ext/new_allocator.h:104: error: passing ‘const std::auto_ptr<A>’ as ‘this’ argument of ‘std::auto_ptr<_Tp>::operator std::auto_ptr_ref<_Tp1>() [with _Tp1 = A, _Tp = A]’ discards qualifiers /usr/include/c++/4.1.2/bits/vector.tcc: In member function ‘void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = std::auto_ptr<A>, _Alloc = std::allocator<std::auto_ptr<A> >]’: /usr/include/c++/4.1.2/bits/stl_vector.h:610: instantiated from ‘void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = std::auto_ptr<A>, _Alloc = std::allocator<std::auto_ptr<A> >]’ ../src/proba.cpp:19: instantiated from here /usr/include/c++/4.1.2/bits/vector.tcc:256: error: passing ‘const std::auto_ptr<A>’ as ‘this’ argument of ‘std::auto_ptr<_Tp>::operator std::auto_ptr_ref<_Tp1>() [with _Tp1 = A, _Tp = A]’ discards qualifiers /usr/include/c++/4.1.2/bits/stl_construct.h: In function ‘void std::_Construct(_T1*, const _T2&) [with _T1 = std::auto_ptr<A>, _T2 = std::auto_ptr<A>]’: /usr/include/c++/4.1.2/bits/stl_uninitialized.h:86: instantiated from ‘_ForwardIterator std::__uninitialized_copy_aux(_InputIterator, _InputIterator, _ForwardIterator, __false_type) [with _InputIterator = __gnu_cxx::__normal_iterator<std::auto_ptr<A>*, std::vector<std::auto_ptr<A>, std::allocator<std::auto_ptr<A> > > >, _ForwardIterator = __gnu_cxx::__normal_iterator<std::auto_ptr<A>*, std::vector<std::auto_ptr<A>, std::allocator<std::auto_ptr<A> > > >]’ /usr/include/c++/4.1.2/bits/stl_uninitialized.h:113: instantiated from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<std::auto_ptr<A>*, std::vector<std::auto_ptr<A>, std::allocator<std::auto_ptr<A> > > >, _ForwardIterator = __gnu_cxx::__normal_iterator<std::auto_ptr<A>*, std::vector<std::auto_ptr<A>, std::allocator<std::auto_ptr<A> > > >]’ /usr/include/c++/4.1.2/bits/stl_uninitialized.h:254: instantiated from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>) [with _InputIterator = __gnu_cxx::__normal_iterator<std::auto_ptr<A>*, std::vector<std::auto_ptr<A>, std::allocator<std::auto_ptr<A> > > >, _ForwardIterator = __gnu_cxx::__normal_iterator<std::auto_ptr<A>*, std::vector<std::auto_ptr<A>, std::allocator<std::auto_ptr<A> > > >, _Tp = std::auto_ptr<A>]’ /usr/include/c++/4.1.2/bits/vector.tcc:279: instantiated from ‘void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = std::auto_ptr<A>, _Alloc = std::allocator<std::auto_ptr<A> >]’ /usr/include/c++/4.1.2/bits/stl_vector.h:610: instantiated from ‘void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = std::auto_ptr<A>, _Alloc = std::allocator<std::auto_ptr<A> >]’ ../src/proba.cpp:19: instantiated from here /usr/include/c++/4.1.2/bits/stl_construct.h:81: error: passing ‘const std::auto_ptr<A>’ as ‘this’ argument of ‘std::auto_ptr<_Tp>::operator std::auto_ptr_ref<_Tp1>() [with _Tp1 = A, _Tp = A]’ discards qualifiers make: *** [src/proba.o] Error 1 It seems to me that there is some kind of problem with consts here. Does this mean that auto_ptr can't be used in vectors?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >