Skip to content

Instantly share code, notes, and snippets.

Robert David Graham robertdavidgraham

Block or report user

Report or block robertdavidgraham

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@robertdavidgraham
robertdavidgraham / robert_3.c
Created Mar 11, 2013
This file is an update to the "robert_2.c" file located here: https://github.com/regehr/str2long_contest This is a contest for parsing integers with no integer overflows. The performance tests use mostly invalid input, which skews the performance results. My "robert_2.c" code is half as fast as the fastest "yang_2.c" code. That's because Yang in…
View robert_3.c
#include "str2long.h"
long str2long_robert_3(const char *str)
{
long result = 0;
int i;
if (str[0] == '-') {
if (str[1] == '\0')
error = 1;
@robertdavidgraham
robertdavidgraham / str2long.c
Created Mar 9, 2013
This file in response to the programming contest at: http://blog.regehr.org/archives/909 The idea is to parse "long int" integers in C, with the following conditions: - accept all valid input - reject all invalid input (such as non-digit characters before the nul termination) - never have an integer overflow in the code The last part is the tric…
View str2long.c
/*
* Code for programming contest at:
* http://blog.regehr.org/archives/909
*/
#include <limits.h>
extern int error;
long str2long(const char *str)
{
long result = 0;
You can’t perform that action at this time.