If self is a properly formatted integer, returns the corresponding value

Returns null otherwise

assert "0xFEu8".to_num  == 254u8
assert "0b10_10".to_num != 10u8

Property definitions

core :: fixed_ints_text $ Text :: to_num
	# If `self` is a properly formatted integer, returns the corresponding value
	# Returns `null` otherwise
	#
	#     assert "0xFEu8".to_num  == 254u8
	#     assert "0b10_10".to_num != 10u8
	fun to_num: nullable Numeric do
		if not is_num then return null
		var s = remove_all('_')
		var ext = s.get_numext
		var trunk = s.strip_numext
		if trunk.strip_numhead == "" then return null
		var trval = trunk.to_i
		if ext == "u8" then
			return trval.to_b
		else if ext == "i8" then
			return trval.to_i8
		else if ext == "i16" then
			return trval.to_i16
		else if ext == "u16" then
			return trval.to_u16
		else if ext == "i32" then
			return trval.to_i32
		else if ext == "u32" then
			return trval.to_u32
		else if ext == "" then
			return trval
		else
			return null
		end
	end
lib/core/text/fixed_ints_text.nit:289,2--318,4