Cross platform/compiler consistent sprintf of floating point numbers

You can switch to LuaJIT. It formats numbers consistently between platforms. From the extensions page: tostring() etc. canonicalize NaN and ±Inf All number-to-string conversions consistently convert non-finite numbers to the same strings on all platforms. NaN results in “nan”, positive infinity results in “inf” and negative infinity results in “-inf”. tonumber() etc. use builtin string … Read more

String format using MultiBinding?

you are trying to bind a string to an object. But StringFormat requires its target to be a string type. try putting a TextBlock in your label content and bind your data to it <StackPanel> <Slider x:Name=”sl1″ Minimum=”10″ Maximum=”100″/> <Slider x:Name=”sl2″ Minimum=”10″ Maximum=”100″/> <Label x:Name=”label13″ Background=”Yellow” Foreground=”Black”> <Label.Content> <TextBlock> <TextBlock.Text> <MultiBinding StringFormat=”{}{0} x {1} Test”> … Read more

The simplest way of printing a portion of a char[] in C

You can use printf(), and a special format string: char *str = “0123456789”; printf(“%.6s\n”, str + 1); The precision in the %s conversion specifier specifies the maximum number of characters to print. You can use a variable to specify the precision at runtime as well: int length = 6; char *str = “0123456789”; printf(“%.*s\n”, length, … Read more