639df89148
A experimental/Intersection A experimental/Intersection/Intersections.h A experimental/Intersection/DataTypes.cpp A experimental/Intersection/QuadraticReduceOrder.cpp A experimental/Intersection/IntersectionUtilities.cpp A experimental/Intersection/CubicIntersection_Tests.h A experimental/Intersection/LineParameteters_Test.cpp A experimental/Intersection/ReduceOrder.cpp A experimental/Intersection/QuadraticIntersection.cpp A experimental/Intersection/Extrema.h A experimental/Intersection/CubicIntersection_TestData.h A experimental/Intersection/QuadraticParameterization_Test.cpp A experimental/Intersection/TestUtilities.cpp A experimental/Intersection/CubicRoots.cpp A experimental/Intersection/QuadraticParameterization.cpp A experimental/Intersection/QuadraticSubDivide.cpp A experimental/Intersection/LineIntersection_Test.cpp A experimental/Intersection/LineIntersection.cpp A experimental/Intersection/CubicParameterizationCode.cpp A experimental/Intersection/LineParameters.h A experimental/Intersection/CubicIntersection.h A experimental/Intersection/CubeRoot.cpp A experimental/Intersection/SkAntiEdge.h A experimental/Intersection/ConvexHull_Test.cpp A experimental/Intersection/CubicBezierClip_Test.cpp A experimental/Intersection/CubicIntersection_Tests.cpp A experimental/Intersection/CubicBezierClip.cpp A experimental/Intersection/CubicIntersectionT.cpp A experimental/Intersection/Inline_Tests.cpp A experimental/Intersection/ReduceOrder_Test.cpp A experimental/Intersection/QuadraticIntersection_TestData.h A experimental/Intersection/DataTypes.h A experimental/Intersection/Extrema.cpp A experimental/Intersection/EdgeApp.cpp A experimental/Intersection/CubicIntersection_TestData.cpp A experimental/Intersection/IntersectionUtilities.h A experimental/Intersection/CubicReduceOrder.cpp A experimental/Intersection/CubicCoincidence.cpp A experimental/Intersection/CubicIntersection_Test.cpp A experimental/Intersection/CubicIntersection.cpp A experimental/Intersection/QuadraticUtilities.h A experimental/Intersection/SkAntiEdge.cpp A experimental/Intersection/TestUtilities.h A experimental/Intersection/CubicParameterization_Test.cpp A experimental/Intersection/LineIntersection.h A experimental/Intersection/CubicSubDivide.cpp A experimental/Intersection/CubicParameterization.cpp A experimental/Intersection/QuadraticBezierClip_Test.cpp A experimental/Intersection/QuadraticBezierClip.cpp A experimental/Intersection/BezierClip_Test.cpp A experimental/Intersection/ConvexHull.cpp A experimental/Intersection/BezierClip.cpp A experimental/Intersection/QuadraticIntersection_TestData.cpp git-svn-id: http://skia.googlecode.com/svn/trunk@3005 2bbb7eff-a529-9590-31e7-b0007b416f81
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
|
|
// snippets that one day may be useful, unused for now...
|
|
|
|
// get sign, exponent, mantissa from double
|
|
// Translate the double into sign, exponent and mantissa.
|
|
long bits = BitConverter.DoubleToInt64Bits(d);
|
|
// Note that the shift is sign-extended, hence the test against -1 not 1
|
|
bool negative = (bits < 0);
|
|
int exponent = (int) ((bits >> 52) & 0x7ffL);
|
|
long mantissa = bits & 0xfffffffffffffL;
|
|
|
|
// Subnormal numbers; exponent is effectively one higher,
|
|
// but there's no extra normalisation bit in the mantissa
|
|
if (exponent==0)
|
|
{
|
|
exponent++;
|
|
}
|
|
// Normal numbers; leave exponent as it is but add extra
|
|
// bit to the front of the mantissa
|
|
else
|
|
{
|
|
mantissa = mantissa | (1L<<52);
|
|
}
|
|
|
|
// Bias the exponent. It's actually biased by 1023, but we're
|
|
// treating the mantissa as m.0 rather than 0.m, so we need
|
|
// to subtract another 52 from it.
|
|
exponent -= 1075;
|
|
|
|
if (mantissa == 0)
|
|
{
|
|
return "0";
|
|
}
|
|
|
|
/* Normalize */
|
|
while((mantissa & 1) == 0)
|
|
{ /* i.e., Mantissa is even */
|
|
mantissa >>= 1;
|
|
exponent++;
|
|
} |