Integer arithmetic

Is there an authoritative specification of the precise rules for arithmetic in ActionScript 3 somewhere?
I need to do some exact integer arithmetic modulo 2^32, such that, e.g. this will output 0 then -1 (that being the least significant 32 bits of the true mathematical result of the multiplications):
var base:int = 1<<30 ;
for( var i:int=0; i<2; i++ ) {
  var a:int = base+i ;
  var b:int = base-i ;
  trace(int(a*b));
According to ECMAScript arithmetic, the multiplication would produce an IEEE-754 double-precision result, which for both times round the loop would be rounded to 2^60 exactly. When that result is converted to an int (again following ECMAScript rules), we get 0 in both cases.
Of course, ECMAScript doesn't know about AS3's int type, and in practical experiments I do indeed get 0 and -1. I'm happy with that, but I'm worried that this may just be due to the whims of the VM at runtime rather than something I can rely on. For example, I could imagine that it would use integer arithmetic in JITted code but fall back to ECMAScript arithmetic in "non-hotspot" interpreted mode. The generated bytecode just uses a generic "multiply" instruction, so a bytecode interpreter would need to look ahead to figure out that it is alright to use integer multiplication. For all I know, it might even depend on whether the Flash player that runs the code is a 32-bit or a 64-bit version.
I have not been able to convince the AS3 compiler (from the open source Flex SDK 4.1.0) generate the "multiply_i" instruction.
So, what's the actual rules? Is it just luck that I get the correct result?

Um, I know that. My question is how can I be certain to get a true int multiplication that preserves the 32 least significant bits of the result and throws away the high ones, instead of a Number multiplication that preserves the most significant 53 bits of the result and throws away the low ones.
After some more investigation I've found that Alchemy compiles a multiplication of C "unsigned"s (which by specification must work modulo 2³²) into just
  public var i0:int, i1:int, ...
  i0 = (i1 * i0)
in Actionscript, eventually producing the same "multiply" bytecode in ABC as I get myself. So perhaps this really is a safe way to do integer multiplication. On the other hand, Alchemy does not have a shining reputation for stability and bug-freedom either ...

Similar Messages

  • How to do integer arithmetic in JSTL?

    I have a foreach loop where I am presenting database results and showing them to the user in 'chunks' (similar to search engine). At the bottom, I also want to have a line of page numbers which refer to the chunks (e.g. 1 2 3 4 ...), and this is where I am having a problem. An integer division in the c:out or in the forEach loop seems to switch JSTL into floating point arithmetic mode, and that results in the <c:out> below producing non-integer values: 1.0 2.0 3.0 .... Is there a way to force it to do integer arithmetic? Or, possibly to format what c:out produces to drop the ".0" part?
    Here's the code:
            <c:forEach var="index"
                      begin="0" end="${searchResultSize}" step="${chunkSize}">
                        <!-- ...snip... build anchor tag ... -->
                        <c:out value="${(index/chunkSize)+1}"/></a>
            </c:forEach>I modified the above to take the calculation our of the c:out, but had same result (1.0 2.0 3.0, etc):
                <c:forEach var="index"
                      begin="0" end="${searchResultSize/chunkSize}" step="1">
                         <!-- ...snip... build anchor tag ... -->
                        <c:out value="${index+1}"/></a>
                </c:forEach>

    To format numbers you use the format tag library, also included with the JSTL
    <fmt:formatNumber value="${(index/chunkSize)+1}" type="number" maxFractionDigits="0" />
    Cheers,
    evnafets

  • 32 bit integer size on 64 bit processor and OS

    Although not strictly a dbx question, I think the audience here is the correct one to bounce this off of:
    I'm curious: Why are 64 bit processes compiled with the -xarch=v9 switch having a 32 bit integer size, versus having 64 bit integer size?
    Although not cast in stone, and implementation dependent, an "int was originally intended to be the "natural" word size of the processor - to use the processor's "natural" word size to improve efficiency (avoid masking, etc).".
    I know you 'force' more 64 bit use (see some of Sun's doc on this below).
    ===============
    The 64-bit Solaris operating environment is a complete 32-bit and 64-bit application and development environment supported by a 64-bit operating system. The 64-bit Solaris operating environment overcomes the limitations of the 32-bit system by supporting a 64-bit virtual address space as well as removing other existing 32-bit system limitations.
    For C, C++, and Fortran software developers, this means the following when compiling with -xarch=v9,v9a, or v9b in a Solaris 7 or Solaris 8 environment:
    Full 64-bit integer arithmetic for 64-bit applications. Though 64-bit arithmetic has been available in all Solaris 2 releases, the 64-bit implementation now uses full 64-bit machine registers for integer operations and parameter passing.
    A 64-bit virtual address space allows programs to access very large blocks of memory.
    For C and C++, the data model is "LP64" for 64-bit applications: long and pointer data types are 64-bits and the programmer needs to be aware that this change may be the cause of many 32-bit to 64-bit conversion issues. The details are in the Solaris 64-bit Developer's Guide, available on AnswerBook2. Also, the lint -errchk=longptr64 option can be used to check a C program's portability to an LP64 environment. Lint will check for assignments of pointer expressions and long integer expressions to plain (32-bit) integers, even for explicit casts.
    The Fortran programmer needs to be aware that POINTER variables in a 64-bit environment are INTEGER*8. Also, certain library routines and intrinsics will require INTEGER*8 arguments and/or return INTEGER*8 values when programs are compiled with -xarch=v9,v9a, or v9b that would otherwise require INTEGER*4.
    Be aware however that even though a program is compiled to run in a 64-bit environment, default data sizes for INTEGER, REAL, COMPLEX, and DOUBLE PRECISION do not change. That is, even though a program is compiled with -xarch=v9, default INTEGER and REAL are still INTEGER*4 and REAL*4, and so on. To use the full features of the 64-bit environment, some explicit typing of variables as INTEGER*8 and REAL*8 may be required. (See also the -xtypemap option.) Also, some 64-bit specific library routines (such as qsort(3F) and malloc64(3F)) may have to be used. For details, see the FORTRAN 77 or Fortran 95 READMEs (also viewable with the f77 or f95 compiler option: -xhelp=readme).
    A: No program is available that specifically invokes 64-bit capabilities. In order to take advantage of the 64-bit capabilities of your system running the 64-bit version of the operating environment, you need to rebuild your applications using the -xarch=v9 option of the compiler or assembler.

    I think that this was basically to keep down the headaches in porting code (and having code that will compile to both 32bit and 64bit object files). int is probably the most common type, so by keeping it at 32bits, the LP64 model has less effect on code that was originally written for 32bit platforms.
    If you want to have portable code (in terms of the sizes of integral types), then you should consider using int32_t, int64_t etc from inttypes.h. Note that this header is post-ANSI C 90, so might not be portable to old C/C++ compilers.
    A+
    Paul

  • Inline functions in C, gcc optimization and floating point arithmetic issues

    For several days I really have become a fan of Alchemy. But after intensive testing I have found several issues which I'd like to solve but I can't without any help.
    So...I'm porting an old game console emulator written by me in ANSI C. The code is working on both gcc and VisualStudio without any modification or crosscompile macros. The only platform code is the audio and video output which is out of scope, because I have ported audio and video witin AS3.
    Here are the issues:
    1. Inline functions - Having only a single inline function makes the code working incorrectly (although not crashing) even if any optimization is enabled or not (-O0 or O3). My current workarround is converting the inline functions to macros which achieves the same effect. Any ideas why inline functions break the code?
    2. Compiler optimizations - well, my project consists of many C files one of which is called flash.c and it contains the main and exported functions. I build the project as follows:
    gcc -c flash.c -O0 -o flash.o     //Please note the -O0 option!!!
    gcc -c file1.c -O3 -o file1.o
    gcc -c file2.c -O3 -o file2.o
    ... and so on
    gcc *.o -swc -O0 -o emu.swc   //Please note the -O0 option again!!!
    mxmlc.exe -library-path+=emu.swc --target-player=10.0.0 Emu.as
    or file in $( ls *.o ) //Removes the obj files
        do
            rm $file
        done
    If I define any option different from -O0 in gcc -c flash.c -O0 -o flash.o the program stops working correctly exactly as in the inline funtions code (but still does not crash or prints any errors in debug). flash has 4 static functions to be exported to AS3 and the main function. Do you know why?
    If I define any option different from -O0 in gcc *.o -swc -O0 -o emu.swc  the program stops working correctly exactly as above, but if I specify -O1, -O2 or O3 the SWC file gets smaller up to 2x for O3. Why? Is there a method to optimize all the obj files except flash.o because I suspect a similar issue as when compilling it?
    3. Flating point issues - this is the worst one. My code is mainly based on integer arithmetic but on 1-2 places it requires flating point arithmetic. One of them is the conversion of 16-bit 44.1 Khz sound buffer to a float buffer with same sample rate but with samples in the range from -1.0 to 1.0.
    My code:
    void audio_prepare_as()
        uint32 i;
        for(i=0;i<audioSamples;i+=2)
            audiobuffer[i] = (float)snd.buffer[i]/32768;
            audiobuffer[i+1] = (float)snd.buffer[i+1]/32768;
    My audio playback is working perfectly. But not if using the above conversion and I have inspected the float numbers - all incorrect and invalid. I tried other code with simple floats - same story. As if alchemy refuses to work with floats. What is wrong? I have another lace whre I must resize the framebuffer and there I have a float involved - same crap. Please help me?
    Found the floating point problem: audiobuffer is written to a ByteArray and then used in AS. But C floats are obviously not the same as those in AS3. Now the floating point is resolved.
    The optimization issues remain! I really need to speed up my code.
    Thank you in advice!

    Dear Bernd,
    I am still unable to run the optimizations and turn on the inline functions. None of the inline functions contain any stdli function just pure asignments, reads, simple arithmetic and bitwise operations.
    In fact, the file containing the main function and those functions for export in AS3 did have memset and memcpy. I tried your suggestion and put the code above the functions calling memset and memcpy. It did not work soe I put the code in a header which is included topmost in each C file. The only system header I use is malloc.h and it is included topmost. In other C file I use pow, sin and log10 from math.h but I removed it and made the same thing:
    //shared.h
    #ifndef _SHARED_H_
    #define _SHARED_H_
    #include <malloc.h>
    static void * custom_memmove( void * destination, const void * source, unsigned int num ) {
      void *result; 
      __asm__("%0 memmove(%1, %2, %3)\n" : "=r"(result) : "r"(destination), "r"(source), "r"(num)); 
      return result; 
    static void * custom_memcpy ( void * destination, const void * source, unsigned int num ) { 
      void *result; 
      __asm__("%0 memcpy(%1, %2, %3)\n" : "=r"(result) : "r"(destination), "r"(source), "r"(num)); 
      return result; 
    static void * custom_memset ( void * ptr, int value, unsigned int num ) { 
      void *result; 
      __asm__("%0 memset(%1, %2, %3)\n" : "=r"(result) : "r"(ptr), "r"(value), "r"(num)); 
      return result; 
    static float custom_pow(float x, int y) {
        float result;
      __asm__("%0 pow(%1, %2)\n" : "=r"(result) : "r"(x), "r"(y));
      return result;
    static double custom_sin(double x) {
        double result;
      __asm__("%0 sin(%1)\n" : "=r"(result) : "r"(x));
      return result;
    static double custom_log10(double x) {
        double result;
      __asm__("%0 log10(%1)\n" : "=r"(result) : "r"(x));
      return result;
    #define memmove custom_memmove
    #define memcpy custom_memcpy
    #define memset custom_memset
    #define pow custom_pow
    #define sin custom_sin
    #define log10 custom_log10 
    #include "types.h"
    #include "macros.h"
    #include "m68k.h"
    #include "z80.h"
    #include "genesis.h"
    #include "vdp.h"
    #include "render.h"
    #include "mem68k.h"
    #include "memz80.h"
    #include "membnk.h"
    #include "memvdp.h"
    #include "system.h"
    #include "loadrom.h"
    #include "input.h"
    #include "io.h"
    #include "sound.h"
    #include "fm.h"
    #include "sn76496.h" 
    #endif /* _SHARED_H_ */ 
    It still behave the same way as if nothing was changed (works incorrectly - displays jerk which does not move, whereby the image is supposed to move)
    As I am porting an emulator (Sega Mega Drive) I use manu arrays of function pointers for implementing the opcodes of the CPU's. Could this be an issue?
    I did a workaround for the floating point problem but processing is very slow so I hear only bzzt bzzt but this is for now out of scope. The emulator compiled with gcc runs at 300 fps on a 1.3 GHz machine, whereby my non optimized AVM2 code compiled by alchemy produces 14 fps. The pure rendering is super fast and the problem lies in the computational power of AVM. The frame buffer and the enulation are generated in the C code and only the pixels are copied to AS3, where they are plotted in a BitmapData. On 2.0 GHz Dual core I achieved only 21 fps. Goal is 60 fps to have smooth audio and video. But this is offtopic. After all everything works (slow) without optimization, and I would somehow turn it on. Suggestions?
    Here is the file with the main function:
    #include "shared.h"
    #include "AS3.h"
    #define FRAMEBUFFER_LENGTH    (320*240*4)
    static uint8* framebuffer;
    static uint32  audioSamples;
    AS3_Val sega_rom(void* self, AS3_Val args)
        int size, offset, i;
        uint8 hardware;
        uint8 country;
        uint8 header[0x200];
        uint8 *ptr;
        AS3_Val length;
        AS3_Val ba;
        AS3_ArrayValue(args, "AS3ValType", &ba);
        country = 0;
        offset = 0;
        length = AS3_GetS(ba, "length");
        size = AS3_IntValue(length);
        ptr = (uint8*)malloc(size);
        AS3_SetS(ba, "position", AS3_Int(0));
        AS3_ByteArray_readBytes(ptr, ba, size);
        //FILE* f = fopen("boris_dump.bin", "wb");
        //fwrite(ptr, size, 1, f);
        //fclose(f);
        if((size / 512) & 1)
            size -= 512;
            offset += 512;
            memcpy(header, ptr, 512);
            for(i = 0; i < (size / 0x4000); i += 1)
                deinterleave_block(ptr + offset + (i * 0x4000));
        memset(cart_rom, 0, 0x400000);
        if(size > 0x400000) size = 0x400000;
        memcpy(cart_rom, ptr + offset, size);
        /* Free allocated file data */
        free(ptr);
        hardware = 0;
        for (i = 0x1f0; i < 0x1ff; i++)
            switch (cart_rom[i]) {
         case 'U':
             hardware |= 4;
             break;
         case 'J':
             hardware |= 1;
             break;
         case 'E':
             hardware |= 8;
             break;
        if (cart_rom[0x1f0] >= '1' && cart_rom[0x1f0] <= '9') {
            hardware = cart_rom[0x1f0] - '0';
        } else if (cart_rom[0x1f0] >= 'A' && cart_rom[0x1f0] <= 'F') {
            hardware = cart_rom[0x1f0] - 'A' + 10;
        if (country) hardware=country; //simple autodetect override
        //From PicoDrive
        if (hardware&8)        
            hw=0xc0; vdp_pal=1;
        } // Europe
        else if (hardware&4)    
            hw=0x80; vdp_pal=0;
        } // USA
        else if (hardware&2)    
            hw=0x40; vdp_pal=1;
        } // Japan PAL
        else if (hardware&1)      
            hw=0x00; vdp_pal=0;
        } // Japan NTSC
        else
            hw=0x80; // USA
        if (vdp_pal) {
            vdp_rate = 50;
            lines_per_frame = 312;
        } else {
            vdp_rate = 60;
            lines_per_frame = 262;
        /*SRAM*/   
        if(cart_rom[0x1b1] == 'A' && cart_rom[0x1b0] == 'R')
            save_start = cart_rom[0x1b4] << 24 | cart_rom[0x1b5] << 16 |
                cart_rom[0x1b6] << 8  | cart_rom[0x1b7] << 0;
            save_len = cart_rom[0x1b8] << 24 | cart_rom[0x1b9] << 16 |
                cart_rom[0x1ba] << 8  | cart_rom[0x1bb] << 0;
            // Make sure start is even, end is odd, for alignment
            // A ROM that I came across had the start and end bytes of
            // the save ram the same and wouldn't work.  Fix this as seen
            // fit, I know it could probably use some work. [PKH]
            if(save_start != save_len)
                if(save_start & 1) --save_start;
                if(!(save_len & 1)) ++save_len;
                save_len -= (save_start - 1);
                saveram = (unsigned char*)malloc(save_len);
                // If save RAM does not overlap main ROM, set it active by default since
                // a few games can't manage to properly switch it on/off.
                if(save_start >= (unsigned)size)
                    save_active = 1;
            else
                save_start = save_len = 0;
                saveram = NULL;
        else
            save_start = save_len = 0;
            saveram = NULL;
        return AS3_Int(0);
    AS3_Val sega_init(void* self, AS3_Val args)
        system_init();
        audioSamples = (44100 / vdp_rate)*2;
        framebuffer = (uint8*)malloc(FRAMEBUFFER_LENGTH);
        return AS3_Int(vdp_rate);
    AS3_Val sega_reset(void* self, AS3_Val args)
        system_reset();
        return AS3_Int(0);
    AS3_Val sega_frame(void* self, AS3_Val args)
        uint32 width;
        uint32 height;
        uint32 x, y;
        uint32 di, si, r;
        uint16 p;
        AS3_Val fb_ba;
        AS3_ArrayValue(args, "AS3ValType", &fb_ba);
        system_frame(0);
        AS3_SetS(fb_ba, "position", AS3_Int(0));
        width = (reg[12] & 1) ? 320 : 256;
        height = (reg[1] & 8) ? 240 : 224;
        for(y=0;y<240;y++)
            for(x=0;x<320;x++)
                di = 1280*y + x<<2;
                si = (y << 10) + ((x + bitmap.viewport.x) << 1);
                p = *((uint16*)(bitmap.data + si));
                framebuffer[di + 3] = (uint8)((p & 0x1f) << 3);
                framebuffer[di + 2] = (uint8)(((p >> 5) & 0x1f) << 3);
                framebuffer[di + 1] = (uint8)(((p >> 10) & 0x1f) << 3);
        AS3_ByteArray_writeBytes(fb_ba, framebuffer, FRAMEBUFFER_LENGTH);
        AS3_SetS(fb_ba, "position", AS3_Int(0));
        r = (width << 16) | height;
        return AS3_Int(r);
    AS3_Val sega_audio(void* self, AS3_Val args)
        AS3_Val ab_ba;
        AS3_ArrayValue(args, "AS3ValType", &ab_ba);
        AS3_SetS(ab_ba, "position", AS3_Int(0));
        AS3_ByteArray_writeBytes(ab_ba, snd.buffer, audioSamples*sizeof(int16));
        AS3_SetS(ab_ba, "position", AS3_Int(0));
        return AS3_Int(0);
    int main()
        AS3_Val romMethod = AS3_Function(NULL, sega_rom);
        AS3_Val initMethod = AS3_Function(NULL, sega_init);
        AS3_Val resetMethod = AS3_Function(NULL, sega_reset);
        AS3_Val frameMethod = AS3_Function(NULL, sega_frame);
        AS3_Val audioMethod = AS3_Function(NULL, sega_audio);
        // construct an object that holds references to the functions
        AS3_Val result = AS3_Object("sega_rom: AS3ValType, sega_init: AS3ValType, sega_reset: AS3ValType, sega_frame: AS3ValType, sega_audio: AS3ValType",
            romMethod, initMethod, resetMethod, frameMethod, audioMethod);
        // Release
        AS3_Release(romMethod);
        AS3_Release(initMethod);
        AS3_Release(resetMethod);
        AS3_Release(frameMethod);
        AS3_Release(audioMethod);
        // notify that we initialized -- THIS DOES NOT RETURN!
        AS3_LibInit(result);
        // should never get here!
        return 0;

  • Selecting #of bits for data types in Java

    hi,
    i would like to know if we can constrain compiler on allocating memory to basic data types, such as int, float, short etc. i would like to read an exactly four byte integer into an int, 2 byte short into a short etc. i need to read these parameters exactly of their specified number of bytes - not more or less - as if i read anything more/less, i will be reading a part of other parameter.
    i know that C allows us to do this by letting us to specify number of bits we like to allocate for each data type (for eg. unsigned int:16; means i need an unsigned int of exactly 16bits (2 bytes long) -no more and no less).
    Is there anything similar i can do in Java?
    any suggestion is greately appreciated.
    Thanks,

    All primitive types in Java are well-defined. In contrast to C/C++, an int in Java is allways 32 bits, using one's complement, a char is allways 16 bits etc.
    Java does not give you direct acces to physical memory - that would compromise the basic design of Java.
    You can read individual bytes from files, and you can do all the integer arithmetic in Java as you can in C/C++. To convert eg. fout bytes to one int, you could do the following:
    byte b1= (some byte value),
         b2,
         b3,
         b4;
    int i= (((b1 << 8) | b2 << 8) | b3 << 8) | b4;
    b1 being the most significant byte, b4 being the least significant.
    Did this answer you questions?

  • SSIS Sql Execute task

    I have two variables say @[User::X] and @[User::Y]. Both are of String data type.  I found the value of X dynamically using some expression in Expression Task and Y is default path.
    Now how to add these two variables and store the result in another variable so that the third variable can be passed to a script task for further checking.
    Anyone help me please.
    Thanks in advance.

    Create a new variable of type String, set EValuateAsExpression as True for it and set expression as
    @[User::X] + @[User::Y]
    In case X and Y holds numerical value and you want to perform integer arithmetic then it should be this
    (DT_I4) @[User::A] + (DT_I4)@[User::B]
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Strange double calculation result with JDK 1.4.2

    Hi,
    I've written a small benchmark to test the power of a Sharp Zaurus PDA. Wanting to compare it with my workstation, I ran it on the PC with JDK1.4.2 Beta and was really surprised to discover that the double calculation of Pi gave a non-correct result: Pi = 3.1413934230804443!!!
    I've tried to isolate the bug without success at the moment. It only happens when run from the Zjb program in JDK1.4.2, either from the command line or from Eclipse.
    The result is correct when run with JDK1.4.1, JDK1.4.1_01, JDK1.1.8 that are also setup on the PC. I extracted the faulty loop and executed the sniplet, but the result is OK. I added the previous lines (running the Ackerman function to test recursivity and stack management): still OK, from Eclipse and command line.
    I think the problem must be a configuration one on my computer: a 2xPII 350, Win2K SP3. Perhaps the 1.4.2 JVM is using an old library... I can't imagine that the Beta JVM would have such problem.
    Or there is a bug in the program which make the stack or the FPU registers break, but I can't find where: all other platforms I tested gave correct results.
    Could someone with a JDK1.4.2 installation test my program and post what were the results for the Pi calculation?
    The 10KB source is available on http://www.alterna.tv/zjb/Zjb.java
    Thanks.

    Yes, it was the Pentium, at the time when 100MHz was top speed...
    My CPUs are supposed not to suffer from that old disease.
    But if it were the case, new JVM can't drop software patches like this. Today, Intel started again the release of the new P4 at 3GHz, after adding a software patch for the hardware defect they had detected...
    I post the code for my small program here as my Web site is frequently down this week:
    import java.awt.BorderLayout;
    import java.awt.Button;
    import java.awt.Color;
    import java.awt.Dialog;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Frame;
    import java.awt.Graphics;
    import java.awt.GridLayout;
    import java.awt.Label;
    import java.awt.List;
    import java.awt.Panel;
    import java.awt.TextField;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.math.BigInteger;
    * Zjb: Zaurus Java Bechmark
    * @author GenePi
    class Zjb
         extends Frame
         static Zjb _mainWindow;
          * Number of benchmark runs.
         private final TextField _runs;
          * Results list
         private final List _results;
          * Wait, program is thinking...
         private final Label _wait;
          * Start button
         private final Button _start;
          * Benchmark running
         private volatile boolean _running = false;
          * Layout the main window.
         Zjb()
              super("Zaurus java benchmark 1.0");
              setLayout(new BorderLayout());
              // Input fields
              Panel top = new Panel(new GridLayout(1, 0));
              top.add(new Label("Number of runs"));
              _runs = new TextField("1");
              top.add(_runs);
              add(top, BorderLayout.NORTH);
              // Results list
              _results = new List();
              add(_results, BorderLayout.CENTER);
              // Start button
              final Panel bottom = new Panel(new FlowLayout(FlowLayout.RIGHT));
              _wait = new Label();
              bottom.add(_wait);
              _start = new Button("Start");
              _start.addActionListener(new ActionListener()
                   public void actionPerformed(final ActionEvent evt)
                        if (!_running)
                             // Clear previous results and start benchmark.
                             _results.clear();
                             _start.setLabel("Stop");
                             _wait.setText("Running...          ");
                             bottom.validate();
                             _running = true;
                        else
                             _start.setLabel("Start");
                             _wait.setText("");
                             _running = false;
              bottom.add(_start);
              // Quit button
              final Button quit = new Button("Quit");
              quit.addActionListener(new ActionListener()
                   public void actionPerformed(final ActionEvent evt)
                        System.exit(0);
              bottom.add(quit);
              add(bottom, BorderLayout.SOUTH);
              // Exit when main window closes
              addWindowListener(new WindowAdapter()
                   public void windowClosing(final WindowEvent evt)
                        System.exit(0);
              Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
              setSize(dim);
              validate();
          * The benchmarks
          * @param runs Number of runs
         private static void runBenchmarks(final int runs)
              long start;
              long end;
              long totalStart;
              long totalEnd;
              // Integer arithmetic
              start = System.currentTimeMillis();
              totalStart = start;
              int resultInt = 0;
              for (int i = 0; i < runs; i++)
                   resultInt = ackerman(3, 9);
                   // resultInt = ackerman(3, 7);
              end = System.currentTimeMillis();
              _mainWindow._results.add("Integer arithmetic: " + ((end - start) / 1000.0) + " s [Ack(3,9)=" + resultInt + "]");
              if (!_mainWindow._running)
                   return;
              // Float and double
              start = System.currentTimeMillis();
              double resultDouble = 0.0;
              for (int i = 0; i < runs; i++)
                   resultDouble = 0.0;
                   for (int j = 1; j < 1000000; j++)
                        resultDouble += 1.0 / ((double) j * (double) j);
                   System.out.println("resultDouble=" + resultDouble);
                   resultDouble = Math.sqrt(resultDouble * 6.0);
              end = System.currentTimeMillis();
              _mainWindow._results.add("Double arithmetic: " + ((end - start) / 1000.0) + " s [Pi=" + resultDouble + "]");
              if (!_mainWindow._running)
                   return;
              // Big operations
              start = System.currentTimeMillis();
              BigInteger resultBig = new BigInteger("1");
              for (int i = 0; i < runs; i++)
                   resultBig = fact(3000);
              end = System.currentTimeMillis();
              _mainWindow._results.add("Infinite arithmetic: " + ((end - start) / 1000.0) + " s [3000!=" + resultBig.toString().substring(1, 20) + "...]");
              if (!_mainWindow._running)
                   return;
              // Strings
              start = System.currentTimeMillis();
              String resultString = null;
              for (int i = 0; i < runs; i++)
                   final String alphabet = " qwertyuioplkjhgfdsazxcvbnm0789456123./*";
                   StringBuffer buf = new StringBuffer();
                   for (int j = 0; j < 100000; j++)
                        int pos = j % alphabet.length();
                        buf.append(alphabet.substring(pos, pos + 1));
                   resultString = buf.toString();
              end = System.currentTimeMillis();
              _mainWindow._results.add("Strings: " + ((end - start) / 1000.0) + " s [" + resultString.substring(1, 20) + "...]");
              if (!_mainWindow._running)
                   return;
              // Drawing
              start = System.currentTimeMillis();
              for (int i = 0; i < runs; i++)
                   final int size = 200;
                   Dialog dialog = new Dialog(_mainWindow, "Drawing...", true);
                   dialog.add(new TestPanel(dialog));
                   dialog.setSize(size, size);
                   dialog.show();
              end = System.currentTimeMillis();
              _mainWindow._results.add("Drawing: " + ((end - start) / 1000.0) + " s");
              if (!_mainWindow._running)
                   return;
              // File copy
              start = System.currentTimeMillis();
              String resultIO = "OK";
              loopIO:
              for (int i = 0; i < runs; i++)
                   final String tempName = "/tmp/Zjb.tmp";
                   try
                        BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempName));
                        for (int j = 0; j < 1000000; j++)
                             out.write((byte) j);
                        out.close();
                        BufferedInputStream in = new BufferedInputStream(new FileInputStream(tempName));
                        for (int j = 0; j < 1000000; j++)
                             int r = in.read();
                             if ((byte) r != (byte) j)
                                  resultIO = "Failed";
                                  System.err.println("Content mismatch at " + j);
                                  break loopIO;
                        in.close();
                        new File(tempName).delete();
                   catch(IOException ioe)
                        resultIO = "Failed";
                        System.err.println(ioe);
                        break loopIO;
              end = System.currentTimeMillis();
              _mainWindow._results.add("Files I/O: " + ((end - start) / 1000.0) + " s [1MB written/read/deleted: " + resultIO + "]");
              totalEnd = end;
              _mainWindow._results.add("");
              _mainWindow._results.add("Total: " + ((totalEnd - totalStart) / 1000.0) + " s");
          * Utility functions: Ackerman function
          * @param m
          * @param n
         private static int ackerman(final int m, final int n)
              if (m == 0)
                   return (n + 1);
              else if (n == 0)
                   return (ackerman(m - 1, 1));
              else
                   return ackerman(m - 1, ackerman(m, (n - 1)));
          * Factorial of big numbers.
          * @param n
          * @return
         private static BigInteger fact(final int n)
              final BigInteger one = new BigInteger("1");
              BigInteger num = new BigInteger("1");
              BigInteger fact = new BigInteger("1");
              for (int i = 2; i <= n; i++)
                   num = num.add(one);
                   fact = fact.multiply(num);
              return fact;
          * Benchmark entry point.
          * @param args Command line arguments
         public static void main(String[] args)
              _mainWindow = new Zjb();
              _mainWindow.show();
              synchronized (Zjb.class)
                   while (true)
                        try
                             Zjb.class.wait(500L);
                        catch (InterruptedException ie)
                             // Wake
                        if (_mainWindow._running)
                             try
                                  runBenchmarks(Integer.parseInt(_mainWindow._runs.getText()));
                             catch (NumberFormatException nfe)
                                  _mainWindow._runs.setText("1");
                                  runBenchmarks(1);
                             _mainWindow._running = false;
                             _mainWindow._start.setLabel("Start");
                             _mainWindow._wait.setText("");
    class TestPanel
         extends Panel
          * The dialog containing the panel.
         private final Dialog _dialog;
         TestPanel(final Dialog dialog)
              _dialog = dialog;
         public void paint(final Graphics g)
              Dimension dim = getSize();
              g.setColor(Color.white);
              g.fillRect(0, 0, dim.width, dim.height);
              for (int i = 0; i < 1000; i++)
                   Color color = new Color((int) (Math.random() * Integer.MAX_VALUE));
                   int x = (int) (Math.random() * dim.width);
                   int y = (int) (Math.random() * dim.height);
                   int width = (int) (Math.random() * dim.width);
                   int height = (int) (Math.random() * dim.height);
                   g.setColor(color);
                   g.fillRect(x, y, width, height);
              g.setColor(Color.white);
              g.fillRect(0, 0, dim.width, dim.height);
              for (int i = 0; i < 1000; i++)
                   Color color = new Color((int) (Math.random() * Integer.MAX_VALUE));
                   int x = (int) (Math.random() * dim.width);
                   int y = (int) (Math.random() * dim.height);
                   int width = (int) (Math.random() * dim.width);
                   int height = (int) (Math.random() * dim.height);
                   g.setColor(color);
                   g.fillOval(x, y, width, height);
              // Hide dialog when finished
              _dialog.hide();
    }

  • Number weeks between two dates which are in same year or different year

    Hi,
    how to calculate the number of weeks between two dates?
    eg. '17-mar-2013' and '27-jun-2013' or '15-jun-2013' and '25-mar-2014'
    Thanks in advance.
    lukx

    A not tested "integer arithmetic" example (to be adjusted to your conceptions if feasible) covering only both dates in the same year and dates in successive years examples.
    consider Setting Up a Globalization Support Environment
    select case when substr(:start_date,1,4) = substr(:end_date,1,4)
                then to_number(to_char(to_date(:end_date,'yyyymmdd'),'iw')) -
                     to_number(to_char(to_date(:start_date,'yyyymmdd'),'iw'))
                when to_number(substr(:end_date,1,4)) - to_number(substr(:start_date,1,4)) = 1
                then to_number(to_char(trunc(to_date(:end_date,'yyyymmdd'),'yyyy') - 1,'iw')) -
                     to_number(to_char(to_date(:start_date,'yyyymmdd'),'iw')) +
                     to_number(to_char(to_date(:end_date,'yyyymmdd'),'iw')) + 1
           end iso_weeks_between
      from dual
    Regards
    Etbin
    the following seems to work for iso weeks treated as buckets
    with
    t as
    (select date '2013-03-17' d1,date '2013-06-17' d2 from dual union all
    select date '2003-12-31',date '2004-01-01' from dual union all
    select date '2004-12-31',date '2005-01-01' from dual union all
    select date '2005-12-31',date '2006-01-01' from dual union all
    select date '2013-12-29',date '2013-12-30' from dual union all
    select date '2016-01-03',date '2016-01-04' from dual union all
    select date '2013-06-15',date '2014-03-25' from dual
    select d1,
           to_number(to_char(d1,'iw')) low_iso_week,
           d2,
           to_number(to_char(d2,'iw')) high_iso_week,
           to_number(to_char(d2,'iw')) - to_number(to_char(d1,'iw')) iso_week_diff,
           case when to_number(to_char(d2,'iw')) - to_number(to_char(d1,'iw')) < 0
                then to_number(to_char(d2,'iw')) - to_number(to_char(d1,'iw')) +
                     case when to_char(trunc(d2,'yyyy'),'iw') = '01'
                          then 52
                          else to_number(to_char(trunc(d2,'yyyy'),'iw'))
                     end
                else to_number(to_char(d2,'iw')) - to_number(to_char(d1,'iw'))
           end iso_weeks_apart
      from t
    Message was edited by: Etbin
    with no Database at hand pencil and paper is too error prone to figure out iso week changes for varioud december - january periods

  • How to generate and catch FP exceptions?

    I use try-catch to trap integer arithmetic exceptions, but how do I set up my program to trap divide by zero and overflow for flotaing point exceptions?
    Is it necessary to have a try-catch for every single FP operation in my program? Like, can I put a "catch-all" piece of code somewhere?

    Division with zero in fp doesn't raise any exceptions since the result is presentable as a floating point number. You can check if the result is NaN or +/- infinity.
    double number = 1.0 / 0.0;
    if (number == Double.POSITIVE_INFINITY) {
    shout("Hey, we just trapped infinity in our variable!!!!");
    }

  • Best type for financial counting

    What is the best type of number if I'd like to count prices with tax and without???

    But fixed point arithmetic is isomorphic to integer arithmetic.
    isomorphic
    <mathematics> Two mathematical objects are isomorphic if they
    have the same structure, i.e. if there is an isomorphism
    between them. For every component of one there is a
    corresponding component of the other.
    i�so�mor�phism
    n.
    2. Mathematics. A one-to-one correspondence between the elements of two sets such that the result of an operation on elements of one set corresponds to the result of the analogous operation on their images in the other set.
    Fixed point? There is no fixed point. One would have to create such a class, and I would imagine it would be done using integers -- probably longs actually. Is that what you're trying to convey that any fixed point handling would be done using integers?

  • What is wrong? errors -88705 and -89130 occur

    Hello!
              I have installed PCI 6024E,but when I open the daq assitant and turn to Connection Diagram,it tells me error -89130.And I can't reset the device,when I do this ,it tells me error -88705.   Is this card bobbled?or there is some other reasons?

    The problem is that the sum, subtract, multiply, and divide methods all use integer arithmetic, so anything less than 1 gets rounded to zero. Try replacing the division symbol '/' by a comma in each method.
    Also, your two-argument constructor doesn't reduce the fraction before storing it, as the assignment stated it should. Also, your one-argument constructor doesn't do what the comments state; it initializes both numerator and denominator to n. If n==0, then you get 0/0 as you have discovered.

  • Can I implement advanced control algorithm with floating-point computations in Ni 7831R ?

    Hi,
    I plan to use a Ni 7831R to control a MIMO nano-positioning stage with servo rate above 20kHz. The control algorithm is based on robust control design and it is much more complex than PID. it also includes floating-point caculations. Can I implement such algorithm with Ni 7831R?
    By the way, is there any way to expand the FPGA gates number for Ni 7831R? Suppose I run out of the FPGA gates (1M), can I add more FPGA gates by buying some different hardware?
    Thanks
    Jingyan
    Message Edited by Jingyan on 08-22-2006 01:45 PM

    Jingyan,
    as long as there is no GPU core implemented on the FPGA these devices only support integer arithmetic. NI's FPGA targets currently don't contain a GPU core so there is no native floating point arithmetic available.
    Still there are several options to implement floating point arithmetic on your own or to work around this target specific limitation. Here are some links that might help:
    Floating-Point Addition in LabVIEW FPGA
    Multiplying, Dividing and Scaling in LabVIEW FPGA
    The NI 7831R uses an 1M FPGA. If your application requires more gates the NI 7833R (3M) is a good solution.
    I hope that helps,
    Jochen Klier
    National Instruments Germany

  • Why use int over double?

    i am using the book beginning java 2. and there is a example showing how the math class works
    the program calculates the radius of a circle in feet and inches given that the area is 100 square feet:
    public class MathCalc
    public static void main(String[]args)
    double radius = 0.0;
    double circlearea= 0.0;
    int feet = 0;
    int inches = 0;
    radius = Math.sqrt(circleArea/Math.PI);
    feet = (int)Math.floor(radius);
    inches = (int)Math.round (12.0 * (radius-feet));
    System.out.println( Feet + "feet" + inches + "inches");
    the output will be 5 feet 8 inches.
    my question is why bother with using 'int', why not simply use 'double' for all your variables?
    in feet and inches 'int' has been used as the result would have been a floating value. so casting as been used. But doesnt that complicate things?cant one just use long for all variables and forgot about worrying whether the value will fit or not.
    thanks
    Ali

    i am using the book beginning java 2. and there is a
    example showing how the math class works
    the program calculates the radius of a circle in feet
    and inches given that the area is 100 square feet:
    public class MathCalc
    public static void main(String[]args)
    double radius = 0.0;
    double circlearea= 0.0;
    int feet = 0;
    int inches = 0;
    radius = Math.sqrt(circleArea/Math.PI);
    feet = (int)Math.floor(radius);
    inches = (int)Math.round (12.0 *
    d (12.0 * (radius-feet));
    System.out.println( Feet + "feet" + inches +
    "inches");
    the output will be 5 feet 8 inches.
    my question is why bother with using 'int', why not
    simply use 'double' for all your variables?There are several reasons to use int (when appropriate) rather than double. More generally, there are several reasons to use integer arithmetic instead of floating point.
    First, integer arithmetic is precise whereas floating point arithmetic is always subject to imprecision. E.g. 6 / 2 always equals 3, 6.0 / 2.0 may equal something like 3.000000000000001.
    Second, (related to the above) the results of integer arithmetic operations will not vary from one machine to the next. The results of the same floating point operation may vary from one machine to the next.
    Third, integer arithmetic is always faster than floating point.
    >
    in feet and inches 'int' has been used as the result
    would have been a floating value. so casting as been
    used. But doesnt that complicate things?The results are cast back to an int because it would look silly and meaningless to print a result of, for instance, 5.00000001 feet, 8.00045 inches.
    cant one just
    use long for all variables and forgot about worrying
    whether the value will fit or not. No. You should never disregard whether the results of arithmetic operations will overflow the size of the word you are using. Even though a long type can contain a pretty huge number, you can still easily overflow it and get nonsensical results.
    Also, a 32 bit word is the native size for most of the machines most of us use. This means that arithmetic operations are fastest on int types (for most of us). This shouldn't be a primary design consideration but it should be taken into account.

  • What is wrong?-posted again and better to understand

    Okay. I saw a few answers. So here is again the program I have to do and the whole code I made:
    -Create a class called Rational for performing arithmetic with fractions. Write a driver program to test your class.
    Use integer variables to represent the private instance variables of the class�the numerator and the denominator. Provide a constructor method that enables an object of this class to be initialized when it is declared. The constructor should store the fraction in reduced form (i.e., the fraction
    2/4
    would be stored in the object as 1 in the numerator and 2 in the denominator). Provide a no- argument constructor with default values in case no initializers are provided. Provide public methods for each of the following:
    -Addition of two Rational numbers. The result of the addition should be stored in reduced form.
    Subtraction of two Rational numbers. The result of the subtraction should be stored in reduced form.
    -Multiplication of two Rational numbers. The result of the multiplication should be stored in reduced form.
    -Division of two Rational numbers. The result of the division should be stored in reduced form.
    -Printing Rational numbers in the form a/b, where a is the numerator and b is the denominator.
    -Printing Rational numbers in floating-point format. (Consider providing formatting capabilities that enable the user of the class to specify the number of digits of precision to the right of the decimal point.)
    MY CODE:
    // Definition of class Rational
    public class Rational extends Object {
    // variables
    private int numerator;
    private int denominator;
    // Rational constructor with no arguments:
    // numerator initialized to 0 and denominator initialized to 1
    public Rational()
    this( 0/1, 0/1 );
    // Rational constructor: numerator initialized to n
    // and denominator initialized to 1
    public Rational( int n )
    this( n/1, n/1 );
    // Rational constructor: numerator initialized to n
    // and denominator initialized to d
    public Rational( int n, int d )
    numerator = n;
    denominator = d;
    // Add two Rational numbers
    public Rational sum( Rational right )
    return new Rational( ( numerator * right.denominator + denominator * right.numerator ) / denominator * right.denominator );
    // Subtract two Rational numbers
    public Rational subtract( Rational right )
    return new Rational( ( numerator * right.denominator - denominator * right.numerator ) / denominator * right.denominator );
    // Multiply two Rational numbers
    public Rational multiply( Rational right )
    return new Rational( ( numerator * right.numerator ) / denominator * right.denominator );
    // Divide two Rational numbers
    public Rational divide( Rational right )
    return new Rational( ( numerator * right.denominator ) / denominator * right.numerator );
    // Reduce the fraction
    private void reduce()
    int gcd = 0;
    int smaller = Math.min( numerator, denominator );
    for ( int x = 2; x <= smaller; x++ )
    if ( numerator % x == 0 && denominator % x == 0 )
    gcd = x;
    if ( gcd != 0 )
    numerator /= gcd;
    denominator /= gcd;
    } // end method reduce
    // Return String representation of a Rational number
    public String toString()
    return numerator + "/" + denominator;
    // Return floating-point String representation of a Rational number
    public String toFloatString()
    return Double.toString(
    ( double ) numerator / denominator );
    } // end public class Rational
    This is the test program I wrote:
    // Java core packages
    import java.awt.*;
    import java.awt.event.*;
    // Java extension packages
    import javax.swing.*;
    public class RationalTest extends JApplet implements ActionListener
    private Rational a, b;
    // GUI components
    private JLabel nlabel1, nlabel2, dlabel1, dlabel2;
    private JTextField numer1Field, numer2Field, denom1Field, denom2Field;
    private JButton additButton, subtractButton, multiplyButton, divideButton;
    // set up applet's GUI
    public void init()
    // obtain content pane and set its layout to FlowLayout
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    // create nlabel1, numer1Field and attach them to content pane
    nlabel1 = new JLabel( "Enter numerator 1:" );
    numer1Field = new JTextField( 5 );
    container.add( nlabel1 );
    container.add( numer1Field );
    // create dlabel1, denomField1 and attach them to content pane
    dlabel1 = new JLabel( "Enter denominator 1:" );
    denom1Field = new JTextField( 5 );
    container.add( dlabel1 );
    container.add( denom1Field );
    // create nlabel2, numer2Field and attach them to content pane
    nlabel2 = new JLabel( "Enter numerator 2:" );
    numer2Field = new JTextField( 5 );
    container.add( nlabel2 );
    container.add( numer2Field );
    // create dlabel2, denomField2 and attach them to content pane
    dlabel2 = new JLabel( "Enter denominator 2:" );
    denom2Field = new JTextField( 5 );
    container.add( dlabel2 );
    container.add( denom2Field );
    // set up additButton and attach it to content pane
    additButton = new JButton( "Add" );
    additButton.addActionListener( this );
    container.add( additButton );
    // set up subtractButton and attach it to content pane
    subtractButton = new JButton( "Subtract" );
    subtractButton.addActionListener( this );
    container.add( subtractButton );
    // set up multiplyButton and attach it to content pane
    multiplyButton = new JButton( "Multiply" );
    multiplyButton.addActionListener( this );
    container.add( multiplyButton );
    // set up divideButton and attach it to content pane
    divideButton = new JButton( "Divide" );
    divideButton.addActionListener( this );
    container.add( divideButton );
    } // end method init
    // handle button events
    public void actionPerformed( ActionEvent actionEvent )
    Rational r;
    a = new Rational( Integer.parseInt( numer1Field.getText() ),
    Integer.parseInt( denom1Field.getText() ) );
    b = new Rational( Integer.parseInt( numer2Field.getText() ),
    Integer.parseInt( denom2Field.getText() ) );
    // process additButton event
    if ( actionEvent.getSource() == additButton )
    r = a.sum( b );
    showStatus( "a + b = " + r + " = " + r.toFloatString() );
    // process subtractButton event
    else if ( actionEvent.getSource() == subtractButton )
    r = a.subtract( b );
    showStatus( "a - b = " + r + " = " + r.toFloatString() );
    // process multiplyButton event
    else if ( actionEvent.getSource() == multiplyButton )
    r = a.multiply( b );
    showStatus( "a * b = " + r + " = " + r.toFloatString() );
    // process divideButton event
    else if ( actionEvent.getSource() == divideButton )
    r = a.divide( b );
    showStatus( "a / b = " + r + " = " + r.toFloatString() );
    } // end method actionPerformed
    } // end public class RationalTest
    The html for the applet is:
    <html>
    <applet code = "RationalTest.class" width = "400" height = "100">
    </applet>
    </html>
    I decided post all this, so you guys have a better idea of what is this about.
    The program compiles without errors, but the calculations (add, subtract, multiply and divide) don't work well.
    If I follow one of the advices someone gave me here [enclose between parenthesis what follows to the symbol "/" in the calculation for the denominator. It would be, for example for the addition:
    return new Rational( ( numerator * right.denominator + denominator * right.numerator ) / ( denominator * right.denominator ) ); ],
    I always get the output, a+b = 0/0 = NAN
    Do you guys think the problem is in the calculations? is it maybe in the reduce method? Well, my instructor told me that the reduce method works okay. And I still don't know/see what is wrong with the calculations.
    Again, the instructor is telling me that

    The problem is that the sum, subtract, multiply, and divide methods all use integer arithmetic, so anything less than 1 gets rounded to zero. Try replacing the division symbol '/' by a comma in each method.
    Also, your two-argument constructor doesn't reduce the fraction before storing it, as the assignment stated it should. Also, your one-argument constructor doesn't do what the comments state; it initializes both numerator and denominator to n. If n==0, then you get 0/0 as you have discovered.

  • 32-bit Intel Core Duo ok with upcoming 64-bit Leopard?

    How well suited is the 32-bit Intel Core Duo in my MacBook Pro to run the future 64-bit Leopard OS? What would be the compromises?
    Should I sell my Core Duo now while I can (maybe...) and upgrade to the 64-bit Core2 Duo. Would a 32-bit chip such as the Core Duo struggle to operate efficiently - or at least as fast as it does under 32-bit Tiger - when run within the 64-bit Leopard OS?
    Cheers
    Ant

    You might find this tidibit (from AnandTech) )interesting, Kappy:
    "Why a 64-bit mode can actually be slower than a 32-bit counterpart
    If all else is equal, a 64-bit MPU will be slower than its 32-bit equivalent. A study conducted by DEC found that, on average, compiling for 64bit programs decreases performance by 5%. This is because 64-bit address pointers occupy more space, resulting in higher data cache miss rates. In fact, 64-bit ISAs still support 64-bit addressing and 32-bit data operands, specifically to keep code size down and the miss rate penalty to a minimum; thus 32-bit integer data is still going to be used when the larger range of 64-bit integers are not needed.
    What good is 64-bit computing?
    There is one good use for 64-bit integer arithmetic: 64-bit flat memory addressing. Offering memory addressing beyond 4GB, 64-bit addressing needs 64-bit general purpose registers and 64-bit integer arithmetic for memory pointer calculations. This obviously has no effect on 32-bit vs. 64-bit performance, since 64-bit memory addressing on a 32-bit processor is a moot point."
    So it's not clear that going 64-bit, in and of itself, would yield any improvement in performance; it may well be worse in some cases (and your analogy might well be true, depending on the cache algorhythms and efficiency).
    Certainly if one processor has a wider memory bus than another, then the first processor should, all else being equal, outperform the second processor. I can't find specs on the memory fetch for the Core Duo and the Core 2 Duo, so I can't say whether or not they differ. The PowerPC G5 processor actually has a 128-bit wide memory fetch (64-bit in and 64-bit out) though it's classified as a "64-bit processor" (based on it's memory address space, I would presume).
    So, as you allude, one has to be careful making performance estimates just based on a desciption of a processor being "32 bit" or "64 bit". We'll have to wait to see reasonable benchmarks between the Core Duo and the Core 2 Duo running a 64-bit OS before we'll really know what advantage, if any, there is.
    Cheers.
    Message was edited by: Dave Sawyer

Maybe you are looking for

  • How to send as an email the spool request?

    Dear Experts, My last post was Email background schedule report to gmail or yahoo mail . I got solution but it's work as a notification which we can say the after report run it triggers mail that report is completed as this time. But i required the t

  • Screen not working of Satellite Pro A

    My sattelite pro, not sure what model because the sticker has worn out, but I think its something like L18850 When I was using it today, it went into sleep, when I rebooted it the screen wouldn't come on. I tried removing the battery, holding power b

  • Factory restore

    hi, I'm holding on to the above mentioned.(forgot is it 8930/8390) i do not know if there is still warranty or not. as i bought it 2nd hand. i did notburn any back up too. i am facing problem with system factory restore. tried F11 upon startup.(could

  • Unordered list displayed horizontally

    Hello, I am really new to Dreamweaver and I tried to complete (succesfully) the video on how to build my first website. Following the instruction was not so complicate... I tried to do pretty much alone the same focusing in creating the button from a

  • When trying to install update I am asked to quit Safari......even though I have........any thoughts?

    When trying to install update I am asked to quit Safari....even though I have.....any thoughts or solutions?