15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Copyright 2010 the V8 project authors. All rights reserved. 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Redistribution and use in source and binary forms, with or without 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// modification, are permitted provided that the following conditions are 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// met: 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// * Redistributions of source code must retain the above copyright 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// notice, this list of conditions and the following disclaimer. 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// * Redistributions in binary form must reproduce the above 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// copyright notice, this list of conditions and the following 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// disclaimer in the documentation and/or other materials provided 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// with the distribution. 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// * Neither the name of Google Inc. nor the names of its 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// contributors may be used to endorse or promote products derived 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// from this software without specific prior written permission. 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef DOUBLE_CONVERSION_FIXED_DTOA_H_ 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define DOUBLE_CONVERSION_FIXED_DTOA_H_ 305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "utils.h" 325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace WTF { 345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace double_conversion { 3602772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Produces digits necessary to print a given number with 385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // 'fractional_count' digits after the decimal point. 395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The buffer must be big enough to hold the result plus one terminating null 405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // character. 415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // 425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The produced digits might be too short in which case the caller has to fill 435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // the gaps with '0's. 445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Example: FastFixedDtoa(0.001, 5, ...) is allowed to return buffer = "1", and 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // decimal_point = -2. 465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // Halfway cases are rounded towards +/-Infinity (away from 0). The call 475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // FastFixedDtoa(0.15, 2, ...) thus returns buffer = "2", decimal_point = 0. 485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // The returned buffer may contain digits that would be truncated from the 495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // shortest representation of the input. 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // This method only works for some parameters. If it can't handle the input it 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) // returns false. The output is null-terminated when the function succeeds. 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool FastFixedDtoa(double v, int fractional_count, 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Vector<char> buffer, int* length, int* decimal_point); 5502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace double_conversion 575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace WTF 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // DOUBLE_CONVERSION_FIXED_DTOA_H_ 61