|
| 1 | + |
| 2 | +var kToFixedLength = |
| 3 | + 1 + /* DoubleToStringConverter::kMaxFixedDigitsBeforePoint*/ 60 + |
| 4 | + 1 + /* DoubleToStringConverter::kMaxFixedDigitsAfterPoint*/ 60; |
| 5 | + |
| 6 | + |
| 7 | +var kToShortestLength = 26; |
| 8 | +var kToExponentialLength = /*DoubleToStringConverter::kMaxExponentialDigits*/ 120 + 8; |
| 9 | +var kToPrecisionLength = /*DoubleToStringConverter::kMaxPrecisionDigits*/ 120 + 7; |
| 10 | + |
| 11 | +function h$_hs_ToShortestLength() { |
| 12 | + return kToShortestLength; |
| 13 | +} |
| 14 | + |
| 15 | +function h$_hs_ToFixedLength() |
| 16 | +{ |
| 17 | + return kToFixedLength; |
| 18 | +} |
| 19 | + |
| 20 | +function h$_hs_ToExponentialLength() |
| 21 | +{ |
| 22 | + return kToExponentialLength; |
| 23 | +} |
| 24 | + |
| 25 | +function h$_hs_ToPrecisionLength() |
| 26 | +{ |
| 27 | + return kToPrecisionLength; |
| 28 | +} |
| 29 | + |
| 30 | +//-------------------- |
| 31 | + |
| 32 | +function h$_hs_Text_ToShortest(value, buf) |
| 33 | +{ |
| 34 | + var conv = value.toString().replace("e+","e"); |
| 35 | + Array.prototype.map.call(conv,function(c,i){ buf.u1[i]=c.charCodeAt(0)}); |
| 36 | + return buf.len = conv.length; |
| 37 | +} |
| 38 | + |
| 39 | +function h$_hs_ToShortest(value, buf) |
| 40 | +{ |
| 41 | + var conv = value.toString().replace("e+","e"); |
| 42 | + Array.prototype.map.call(conv,function(c,i){ buf.u8[i]=c.charCodeAt(0)}); |
| 43 | + return buf.len = conv.length; |
| 44 | +} |
| 45 | + |
| 46 | +//-------------------- |
| 47 | + |
| 48 | +function h$_hs_Text_ToFixed(value, buf, ndigits) |
| 49 | +{ |
| 50 | + var conv = value.toFixed(Math.min(20,ndigits))+ "0".repeat(Math.max(0,ndigits - 20)); |
| 51 | + Array.prototype.map.call(conv,function(c,i){ buf.u1[i]=c.charCodeAt(0)}); |
| 52 | + return buf.len = conv.length; |
| 53 | +} |
| 54 | + |
| 55 | +function h$_hs_ToFixed(value, buf, unused, ndigits) |
| 56 | +{ |
| 57 | + var conv = value.toFixed(Math.min(20,ndigits))+ "0".repeat(Math.max(0,ndigits - 20)); |
| 58 | + Array.prototype.map.call(conv,function(c,i){ buf.u8[i]=c.charCodeAt(0)}); |
| 59 | + return buf.len = conv.length; |
| 60 | +} |
| 61 | + |
| 62 | +//-------------------- |
| 63 | + |
| 64 | +function h$_hs_Text_ToExponential(value, buf, ndigits) |
| 65 | +{ |
| 66 | + var conv = value.toExponential(ndigits).replace("e+","e"); |
| 67 | + Array.prototype.map.call(conv,function(c,i){ buf.u1[i]=c.charCodeAt(0)}); |
| 68 | + return buf.len = conv.length; |
| 69 | +} |
| 70 | + |
| 71 | +function h$_hs_ToExponential(value, buf, unused, ndigits) |
| 72 | +{ |
| 73 | + var conv = value.toExponential(ndigits).replace("e+","e"); |
| 74 | + Array.prototype.map.call(conv,function(c,i){ buf.u8[i]=c.charCodeAt(0)}); |
| 75 | + return buf.len = conv.length; |
| 76 | +} |
| 77 | + |
| 78 | +//-------------------- |
| 79 | + |
| 80 | +function h$_hs_Text_ToPrecision(value, buf, ndigits) |
| 81 | +{ |
| 82 | + var conv = value.toPrecision(Math.min(21,ndigits)) + "0".repeat(Math.max(0,ndigits - 21)); |
| 83 | + Array.prototype.map.call(conv,function(c,i){ buf.u1[i]=c.charCodeAt(0)}); |
| 84 | + return buf.len = conv.length; |
| 85 | +} |
| 86 | + |
| 87 | +function h$_hs_ToPrecision(value, buf, unused, ndigits) |
| 88 | +{ |
| 89 | + var conv = value.toPrecision(Math.min(21,ndigits))+ "0".repeat(Math.max(0,ndigits - 21)); |
| 90 | + Array.prototype.map.call(conv,function(c,i){ buf.u8[i]=c.charCodeAt(0)}); |
| 91 | + return buf.len = conv.length; |
| 92 | +} |
0 commit comments