/// <summary> /// Writes a floating point number to a char array. /// </summary> /// <param name="value">The value to write</param> /// <param name="chars">The array to write to</param> /// <param name="offset">Position in the array to write to</param> /// <param name="precision">How many precision digits to include</param> /// <returns>Total number of characters that were written to the array</returns> public static unsafe int DoubleToUnicode(double value, char[] chars, int offset, int precision) { fixed(char *charptr = chars) { return(CharConverter.DoubleToUnicode(value, charptr, chars.Length, offset, precision)); } }
/// <summary> /// Writes a numeric value to a char array in base 10. /// </summary> /// <param name="value">number to write</param> /// <param name="chars">array to write to.</param> /// <param name="offset">position in the array to write number to</param> /// <param name="numbase">the numeric base to write the number in</param> /// <returns>Total number of characters that were written to the array</returns> public static unsafe int UlongToUnicode(ulong value, char[] chars, int offset) { fixed(char *charptr = chars) { return(CharConverter.UlongToUnicode(value, charptr, chars.Length, offset)); } }
public static unsafe void AppendPrimitive(this StringBuilder stringBuilder, ulong value) { char *buffer = stackalloc char[20]; var count = CharConverter.UlongToUnicode(value, buffer, 20, 0); stringBuilder.Append(buffer, count); }
public static unsafe void AppendPrimitive(this StringBuilder stringBuilder, uint value) { char *buffer = stackalloc char[12]; var count = CharConverter.UintToUnicode(value, buffer, 12, 0); stringBuilder.Append(buffer, count); }
/// <summary> /// Writes a numeric value to a char array in base 10. /// </summary> /// <param name="value">number to write</param> /// <param name="chars">array to write to.</param> /// <param name="offset">position in the array to write number to</param> /// <param name="numbase">the numeric base to write the number in</param> /// <returns>Total number of characters that were written to the array</returns> public static int IntToUnicode(int value, char[] chars, int offset) { if (value < 0) { int written = CharConverter.UintToUnicode((uint)-value, chars, offset + 1); // Add the minus afterwards to avoid modifying the char array incase of out of bounds. chars[offset] = '-'; return(++written); } else { return(CharConverter.UintToUnicode((uint)value, chars, offset)); } }
/// <summary> /// Writes a numeric value to a char array in base 10. /// </summary> /// <param name="value">number to write</param> /// <param name="chars">pointer to write to</param> /// <param name="length">size of the pointer</param> /// <param name="offset">where in the pointer to write to</param> /// <returns>Total number of characters that were written to the char pointer</returns> public static unsafe int LongToUnicode(long value, char *chars, int length, int offset) { if (value < 0) { int written = CharConverter.UlongToUnicode((ulong)-value, chars, length, offset + 1); // Add the minus afterwards to avoid modifying the char array incase of out of bounds. chars[offset] = '-'; return(++written); } else { return(CharConverter.UlongToUnicode((ulong)value, chars, length, offset)); } }
public void WriteULong(ulong ul) { this.Reserve(20); this.usagebound += CharConverter.UlongToUnicode(ul, this.buffer, this.usagebound); }
public void WriteUInt(uint ui) { this.Reserve(11); this.usagebound += CharConverter.UintToUnicode(ui, this.buffer, this.usagebound); }
public void WriteUShort(ushort us) { this.Reserve(6); this.usagebound += CharConverter.UintToUnicode(us, this.buffer, this.usagebound); }
public void WriteByte(byte b) { this.Reserve(4); this.usagebound += CharConverter.UintToUnicode(b, this.buffer, this.usagebound); }
public void WriteLong(long l) { this.Reserve(20); this.usagebound += CharConverter.LongToUnicode(l, this.buffer, this.usagebound); }
public void WriteInt(int i) { this.Reserve(11); this.usagebound += CharConverter.IntToUnicode(i, this.buffer, this.usagebound); }
public void WriteSByte(sbyte sb) { this.Reserve(4); this.usagebound += CharConverter.IntToUnicode(sb, this.buffer, this.usagebound); }
/// <summary> /// Writes a floating point number to a char array. /// </summary> /// <param name="value">The value to write</param> /// <param name="chars">The char pointer to write to</param> /// <param name="length">The total length of the char pointer</param> /// <param name="offset">Position in the char pointer to write to</param> /// <param name="precision">How many precision digits to include</param> /// <returns>Total number of characters that were written to the char pointer</returns> public static unsafe int FloatToUnicode(float value, char *chars, int length, int offset, int precision) => CharConverter.DoubleToUnicode(value, chars, length, offset, precision);
/// <summary> /// Writes a floating point number to a char array in base 10. /// </summary> /// <param name="value">The value to write</param> /// <param name="chars">The array to write to</param> /// <param name="offset">Position in the array to write to</param> /// <param name="precision">How many precision digits to include</param> /// <returns>Total number of characters that were written to the array</returns> public static int FloatToUnicode(float value, char[] chars, int offset, int precision) => CharConverter.DoubleToUnicode(value, chars, offset, precision);
public void WriteFloat(float f, int remainders) { this.Reserve(20); this.usagebound += CharConverter.FloatToUnicode(f, this.buffer, this.usagebound, remainders); }
public void WriteDouble(double f, int remainders) { this.Reserve(20); this.usagebound += CharConverter.DoubleToUnicode(f, this.buffer, this.usagebound, remainders); }
public void WriteShort(short s) { this.Reserve(6); this.usagebound += CharConverter.IntToUnicode(s, this.buffer, this.usagebound); }