On Monday, 11 August 2014 at 15:30:30 UTC, Justin Whear wrote:
1. http://dlang.org/phobos/std_bitmanip.html#.FloatRep
Could someone briefly outline the algorithm that converts the
fraction part of FloatRep into a string in base 10?
My first guess is
sum = 0;
foreach (bit_index i,
On Wednesday, 13 August 2014 at 07:51:30 UTC, Nordlöw wrote:
1. http://dlang.org/phobos/std_bitmanip.html#.FloatRep
Can somebody shortly explain why
import std.stdio, std.algorithm, std.range, std.stdio,
std.bitmanip;
void main(string args[])
{
{
float x = 1.23e10;
auto
Is there a way to separately stringify/print the mantissa and
exponent of a floating point?
I want this in my pretty-printing module to produce something like
1.2 \cdot 10^3
instead of
1.2e3
I could of course always split on the e but that is kind of
non-elegant, I believe.
Here's my current try:
string toMathML(T)(T x) @trusted /** pure */ if
(isFloatingPoint!T)
{
import std.conv: to;
import std.algorithm: findSplit; //
immutable parts = to!string(x).findSplit(e);
if (parts[2].length == 0)
return parts[0];
else
return parts[0]
On Mon, 11 Aug 2014 13:47:13 +, Nordlöw wrote:
Is there a way to separately stringify/print the mantissa and exponent
of a floating point?
I want this in my pretty-printing module to produce something like
1.2 \cdot 10^3
instead of
1.2e3
I could of course always split on the
On Monday, 11 August 2014 at 14:15:05 UTC, Nordlöw wrote:
Here's my current try:
string toMathML(T)(T x) @trusted /** pure */ if
(isFloatingPoint!T)
{
import std.conv: to;
import std.algorithm: findSplit; //
immutable parts = to!string(x).findSplit(e);
if (parts[2].length ==
On Monday, 11 August 2014 at 15:37:29 UTC, Dominikus Dittes
Scherkl wrote:
Should be patrs[1], he?
No, parts[1] contains a slice to the e separating the mantissa
from the exponent.
On Monday, 11 August 2014 at 15:30:30 UTC, Justin Whear wrote:
1. http://dlang.org/phobos/std_bitmanip.html#.FloatRep
Great! Thx.
On Monday, 11 August 2014 at 15:30:30 UTC, Justin Whear wrote:
1. http://dlang.org/phobos/std_bitmanip.html#.FloatRep
I'm lacking a use case. See
http://dlang.org/library/std/bitmanip/FloatRep.html
Is unsafe
*(cast(FloatRep*)float_instance)
the only way to use this?