MCPcopy Create free account
hub / github.com/ablab/spades / convertFromStringSpecials

Method convertFromStringSpecials

ext/src/llvm/APFloat.cpp:2793–2861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2791}
2792
2793bool IEEEFloat::convertFromStringSpecials(StringRef str) {
2794 const size_t MIN_NAME_SIZE = 3;
2795
2796 if (str.size() < MIN_NAME_SIZE)
2797 return false;
2798
2799 if (str.equals("inf") || str.equals("INFINITY") || str.equals("+Inf")) {
2800 makeInf(false);
2801 return true;
2802 }
2803
2804 bool IsNegative = str.front() == '-';
2805 if (IsNegative) {
2806 str = str.drop_front();
2807 if (str.size() < MIN_NAME_SIZE)
2808 return false;
2809
2810 if (str.equals("inf") || str.equals("INFINITY") || str.equals("Inf")) {
2811 makeInf(true);
2812 return true;
2813 }
2814 }
2815
2816 // If we have a 's' (or 'S') prefix, then this is a Signaling NaN.
2817 bool IsSignaling = str.front() == 's' || str.front() == 'S';
2818 if (IsSignaling) {
2819 str = str.drop_front();
2820 if (str.size() < MIN_NAME_SIZE)
2821 return false;
2822 }
2823
2824 if (str.startswith("nan") || str.startswith("NaN")) {
2825 str = str.drop_front(3);
2826
2827 // A NaN without payload.
2828 if (str.empty()) {
2829 makeNaN(IsSignaling, IsNegative);
2830 return true;
2831 }
2832
2833 // Allow the payload to be inside parentheses.
2834 if (str.front() == '(') {
2835 // Parentheses should be balanced (and not empty).
2836 if (str.size() <= 2 || str.back() != ')')
2837 return false;
2838
2839 str = str.slice(1, str.size() - 1);
2840 }
2841
2842 // Determine the payload number's radix.
2843 unsigned Radix = 10;
2844 if (str[0] == '0') {
2845 if (str.size() > 1 && tolower(str[1]) == 'x') {
2846 str = str.drop_front(2);
2847 Radix = 16;
2848 } else
2849 Radix = 8;
2850 }

Callers

nothing calls this directly

Calls 9

equalsMethod · 0.80
startswithMethod · 0.80
sizeMethod · 0.45
frontMethod · 0.45
drop_frontMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
sliceMethod · 0.45
getAsIntegerMethod · 0.45

Tested by

no test coverage detected