pastebin

Paste #68000: Untitled Java paste by 77.202.219.94

	/**
	 * Parse a human-readable string possibly including SI units into an integer.
	 * @throws NumberFormatException
	 *             if the string is not parseable
	 */
	public static int parseSIInt(String s) throws NumberFormatException {
		int res = 1;
		int x = s.length() - 1;
		int idx;
		try {
			long[] l =
				{
					1000,
					1 << 10,
					1000 * 1000,
					1 << 20,
					1000 * 1000 * 1000,
					1 << 30 };
			while ((x >= 0)
				&& ((idx = "kKmMgG".indexOf(s.charAt(x))) != -1)) {
				x--;
				res *= l[idx];
			}
			res *= Double.parseDouble(s.substring(0, x + 1));
		} catch (ArithmeticException e) {
			res = Integer.MAX_VALUE;
			throw new NumberFormatException(e.getMessage());
		}
		return res;
	}

New paste

  Language:
Private   — Wrap long lines  —  3 + 1 =   —  

About this pastebin

Welcome to the bulix.org / pastebin. Please don't use this pastebin for illegal purposes, defamation or kitten-squashing.

This pastebin is written using PHP and MySQL and relies on Alex Gorbatchev's syntax hhighlighter (JavaScript based). To avoid spam, you will be required to complete a small mathematical challenge when adding a new paste.

New! Try the pastebin command-line tool: paste.py (requires Python and python-beautifulsoup).

30 more recent public pastes


# Title Type Date
1 Untitled ASCII paste by 88.159.82.79 ASCII 16 Mar 2010, 01:02
2 Untitled ASCII paste by 89.216.89.51 ASCII 15 Mar 2010, 18:22
3 Untitled ASCII paste by 89.216.89.51 ASCII 15 Mar 2010, 18:21
4 Untitled ASCII paste by 89.216.89.51 ASCII 15 Mar 2010, 18:20
5 wrapper.log error msg - Cybertroll ASCII 15 Mar 2010, 15:11
6 Untitled ASCII paste by 203.87.12.85 ASCII 15 Mar 2010, 07:10
7 Untitled ASCII paste by 82.247.183.72 ASCII 14 Mar 2010, 11:36
8 Untitled ASCII paste by 212.126.160.18 ASCII 10 Mar 2010, 16:41
9 QT buttons ASCII 10 Mar 2010, 16:01
10 LinqPad Azure Table storage C# 10 Mar 2010, 08:09
11 Jasssystem ASCII 10 Mar 2010, 06:59
12 Untitled ASCII paste by 82.247.183.72 ASCII 09 Mar 2010, 21:10
13 Untitled ASCII paste by 82.247.183.72 ASCII 09 Mar 2010, 20:53
14 Untitled ASCII paste by 124.85.38.49 ASCII 09 Mar 2010, 13:02
15 Untitled ASCII paste by 77.57.166.143 ASCII 09 Mar 2010, 00:23
16 number-bullet.scm ASCII 08 Mar 2010, 10:57
17 numbers.scm ASCII 08 Mar 2010, 10:57
18 Untitled ASCII paste by 77.57.166.143 ASCII 08 Mar 2010, 03:12
19 Untitled ASCII paste by 82.247.183.72 ASCII 07 Mar 2010, 14:46
20 Untitled ASCII paste by 82.247.183.72 ASCII 07 Mar 2010, 14:45
21 Untitled ASCII paste by 82.247.183.72 ASCII 07 Mar 2010, 14:40
22 Untitled ASCII paste by 82.73.10.131 ASCII 06 Mar 2010, 23:39
23 Untitled ASCII paste by 82.247.183.72 ASCII 05 Mar 2010, 11:58
24 Untitled ASCII paste by 82.247.183.72 ASCII 05 Mar 2010, 11:55
25 Untitled ASCII paste by 82.247.183.72 ASCII 05 Mar 2010, 09:20
26 Untitled ASCII paste by 90.35.20.41 ASCII 04 Mar 2010, 14:22
27 Untitled ASCII paste by 82.247.183.72 ASCII 04 Mar 2010, 11:53
28 Untitled ASCII paste by 82.247.183.72 ASCII 04 Mar 2010, 11:53
29 Untitled ASCII paste by 82.247.183.72 ASCII 03 Mar 2010, 17:01
30 GoUrXoUjFyycZcLdUt Java 02 Mar 2010, 21:32

Powered by the Bulix.org Code Pastebin, by Maxime Petazzoni. View pastebin statistics.