Tag Archives: C#

Sometimes it’s all too much…

Argh #include <stdio.h> #include <math.h> #include <fenv.h>   int main () { // don’t set rounding here double ten0 = sin(pow(10.0,22));   fesetround(FE_DOWNWARD); double ten1 = sin(pow(10.0,22));   fesetround(FE_UPWARD); double ten2 = sin(pow(10.0,22));   fesetround(FE_TONEAREST); double ten3 = sin(pow(10.0,22));   fesetround(FE_TOWARDZERO); double ten4 = sin(pow(10.0,22));   printf( "Default: %f\n" "Downward: %f\n" "Upward: %f\n" "ToNearest: %f\n" [...]

Things I’d like to see in C#: Conditional interface implementation

To explain this, imagine you are designing a type Wrapper<T>, which is just a simple wrapper around a type T. class Wrapper<T> { T value; public Wrapper(T theObject) { value = theObject; } // Some other methods… } Now, since this is a just a wrapper around some type T, we would like to implement [...]

An Anachronistic Aphorism

Some programming languages manage to absorb change, but withstand progress. —‘Epigrams in Programming’, Alan J. Perlis, ACM SIGPLAN Sept. 1982

Ridiculous UTF-8 character counting

So, Colin Percival has posted a UTF-8 strlen which improves on my previous post. While his code runs slightly slower than mine on my PC, I assume that’s because his code is aimed at a 64-bit architecture. With 32-bits (reading 4 bytes at a time, instead of 8 ) it doesn’t quite get the same [...]