/// <summary> /// Try to parse StringEntity to double. /// Cannot accept whitespaces, comma insertion, and hex format (these are differ from official C# float.TryParse()). /// Use TryParseHex(out T) for hex data. /// This function calls the delegate of BurstCompiler.CompileFunctionPointer(). /// </summary> /// <typeparam name="T"></typeparam> /// <param name="source"></param> /// <param name="result"></param> /// <returns></returns> public static bool TryParse <T>(T source, out double result) where T : IParseExt { TryParseBurstCompile._tryParseFloat64Delegate((Char16 *)source.GetUnsafePtr(), source.Length, out bool success, out result); return(success); }
/// <summary> /// Try to parse StringEntity to float. /// Cannot accept whitespaces, comma insertion, and hex format (these are differ from official C# float.TryParse()). /// Use TryParseHex(out T) for hex data. /// This function calls the delegate of BurstCompiler.CompileFunctionPointer(). /// </summary> /// <typeparam name="T"></typeparam> /// <param name="source"></param> /// <param name="result"></param> /// <returns></returns> public static bool TryParse <T>(T source, out float result) where T : IParseExt { result = 0.0f; TryParseBurstCompile._tryParseFloat64Delegate((Char16 *)source.GetUnsafePtr(), source.Length, out bool success, out double tmp); if (!success) { return(false); } float f_cast = (float)tmp; if (float.IsInfinity(f_cast)) { return(false); } result = f_cast; return(true); }