Re: Extending operator + (plus) for byte/short type

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Arne Vajhøj wrote:
Jeroen Mostert wrote:
K Viltersten wrote:
While i know that the bytes are cheap today,
i still prefer to use a byte (or short) when i know that the entity counted isn't larger
than 255 (or 65k). However, it's a real pain
to cast every time i perform an operation.

Example:
private byte a, b;
public byte MyProperty
{ get { return (byte)(a + b); } }

It *should* be a pain. You get a good indication of the work the CPU has to do.

Operating on 32-bit integers is vastly more efficient for a 32-bit CPU than operating on bytes.

Usually X bit CPU means that the virtual addresses are X bits wide.

It does not say anything about register width, memory bus width, width
of instruction operands etc..

True, true -- although the term "X-bit CPU" is actually vague enough to indicate any of these things.

Public properties should basically never be smaller than an int, it doesn't pay (unless, again, you can show that you really need the memory) or when they're part of a predefined interop structure.

I would tend to let the modeling determine the type.

If your model actually includes 16-bit and 8-bit types, sure. Most models don't happen to include things like "integers with a range of -32,768 to 32,767", though -- and when they do, modeling them with the most convenient integer type (rather than the one that would fit the range exactly) is still not a bad idea.

--
J.
.



Relevant Pages

  • Re: A new one on me.
    ... If you use Speedfan from almico.com, is the CPU temperature below 65C? ... hour run, error free, as proof the computer is operating well. ... As an alternative test, you can boot a Linux LiveCD, such as Ubuntu from ...
    (microsoft.public.windowsxp.general)
  • Re: A new one on me.
    ... I have executed your suggestions and found the PC clean, the condition of the capacitors around the processor socket appear to be in good condition, and the memory tests OK as well. ... If you use Speedfan from almico.com, is the CPU temperature below 65C? ... hour run, error free, as proof the computer is operating well. ...
    (microsoft.public.windowsxp.general)
  • Re: will water cooling help lower ambient room temps? good systems for a newbie?
    ... The device is still supposed to work within that operating range ... If the operating range for a CPU is up to 80C and ... desparately trying to lower temperatures then they've told you their CPU ... With his high ambient temps, it would be normal to see higher than normal ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: will water cooling help lower ambient room temps? good systems for a newbie?
    ... The device is still supposed to work within that operating range ... If the operating range for a CPU is up to 80C and ... desparately trying to lower temperatures then they've told you their CPU ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: Chat server : Threading in select call
    ... on the same CPU. ... So when does the kernel get around to handling the fault? ... introduction of additional CPU instructions or I/O operations magically fits ... and operating at peak instructions ...
    (comp.unix.programmer)