Converting involves changing data from one data type or format to another.
1
vote
2answers
28 views
Large number to many characters
My goal is to take any size number, and convert it to a string of smaller characters that represent the concatenation of the binary expansion of the number. To illustrate what I am talking about, here ...
3
votes
1answer
43 views
Bi-directional atoi()
I am implementing atoi() by traversing a string from the beginning as well as from the end. Is there anything I can improve?
...
15
votes
3answers
1k views
Converting an IP
I've written a DNS tool in Node and would like to know if there's a better and more efficient way of handling the conversion from an IP to a long. I'm not too good at bitwise just yet and would like ...
5
votes
2answers
56 views
Convert string to multiline text
I made this method that takes any string and transforms it into a multiline text l; each line having the max (character) length specified by the rowLength ...
4
votes
1answer
17 views
Converting the integers to their equivalent string representations
I have the following function which converts an integer (such as 103 to its string representation "one hundred three"):
...
6
votes
1answer
140 views
Converting any PHP function toString() like in JS
In JavaScript, any function is basically an object on which you can call (function(){}).toString() to get it's underlying code as a string.
I'm working on a ...
3
votes
1answer
77 views
Converting from std::wstring to std::string in Linux
I was bothered by inability of C++ to mix cout and wcout in the same program - so I've found this question:
Converting between ...
4
votes
1answer
59 views
Convert hex string to byte array
The goal is to convert a hex string to a byte array with the following requirements:
\$O(1)\$ additional space apart from input and output.
\$O(n)\$ runtime
This mostly just prohibits creating a ...
3
votes
1answer
58 views
Displaying TimeSpan as largest interval (with units) - Part II
[This is a follow-up question to: Displaying TimeSpan as largest interval (with units). The code listed here has been refactored since the original question was posed. Please note that the scope of ...
5
votes
3answers
283 views
Displaying TimeSpan as largest interval (with units)
The following method is used in a call center application to display an approximation of remaining time. The call center telephone operator would inform the caller that they could perform their ...
1
vote
0answers
9 views
Extra elements in Python list [migrated]
Using Cython, I am trying to convert a Python list to a Cython array, and vice versa. The Python list contains numbers from the range 0 - 255, so I specify the type of the array as an ...
5
votes
6answers
81 views
Readability of JavaScript shorthand for converting strings to numbers with default value
This is perfectly readable code to me, but I'm afraid it may be too confusing to others. What do you think?
Note that I'm not interested in validation of the input here (validation will happen long ...
5
votes
1answer
75 views
Generic Converter framework
I find myself frequently converting between formats so I have come up with the following conversion framework:
The converter interface surfaces a method to convert from a source type to a target ...
0
votes
1answer
22 views
Optimization of a Qt QByteArray conversion
I wrote a function to convert a hexadecimal string representation (like 0x00) of some binary data to the data itself.
How can I improve this code?
...
3
votes
1answer
50 views
Conversion from postfix to infix in C
Just over half way through in K&R, came across an exercise to convert from postfix ("reverse-Polish") notation to infix (standard) notation.
Basically I'm posting here to see if there is ...
7
votes
3answers
269 views
Number to words in left to right direction
I have faced one logical question in an interview:
If we enter a number it will convert into individual strings and display in same order.
Ex: If I enter 564 ...
2
votes
0answers
37 views
Length Conversions
I'm trying to create some helper functions that will allow me to convert from one unit of measurement to another. I eventually will need to be able to do speeds and temperatures as well, but so far, ...
4
votes
3answers
145 views
Converting an integer to binary, hex, and octal
I've started caring about standards and the beauty of my code. I doubt whether I've written it correctly and aesthetically. Can you please judge this simple, exemplary program? I want to know of any ...
2
votes
1answer
76 views
Web service - getting data from SQL and adding to Object
I have created a class called CommandMessages
...
2
votes
3answers
125 views
Python Barcode Generator
I was asked to provide some example code for a job interview and didn't have anything to offer, so I wrote the following function.
A barcode generator may seem a bit basic, but there's some logic ...
3
votes
1answer
35 views
Replacing Perisan and Arabic digits
I'm using this function to replace UTF-8 characters representing numbers in text with 'normal' digits.
I'm wondering if this is optimized code since this is using two ...
4
votes
1answer
80 views
Program for importing autotask contracts into dynamics CRM 2011
We regularly have to convert a bunch of autotask Contracts to a custom CRM entity because we have employees who don't work in Autotask but need those contracts. I wrote the above code to handle this ...
6
votes
4answers
199 views
Better way to repeatedly use istringstream in “counting minutes” challenge
I was doing this easy challenge "Counting Minutes I" from Coderbyte.com where you just calculate the number of minutes between two given times.
The second time is always after the first, although it ...
3
votes
0answers
56 views
Parsing an infix notation expression and converting to reverse polish notation
I'm pretty new to Go, and I do not know the best or idiomatic ways to do most of the stuff, so I'd appreciate feedback on how to make my code better, faster or more idiomatic.
My program is a set of ...
6
votes
5answers
154 views
Convert sequence of number into display string
My requirement is to convert a sequence of numbers into a display string as below.
Example
Input
1,2,3,4,5,7,7,8,8,8,10,15,10,11,12,88,87,86
Output
1-5,7-8,10-12,15,86-88
...
6
votes
1answer
102 views
Binary converter and sufficient tests
I just finished writing a basic binary conversion class in Ruby. I'm curious to see if anyone has suggestions for improvements. In particular, I'm looking for the cleanest, shortest, most succinct ...
6
votes
1answer
142 views
BBCode to HTML converter using functional programming
I was inspired to write a BBCode to HTML converter as I'm currently learning functional programming. I wanted achieve functional cohesion. jsFiddle
I'd like feedback on:
structuring of the code. ...
3
votes
1answer
47 views
Infix to postix conversion
I'm looking for code review, optimizations and best practices.
Also verifying complexity to be O(n), where n is the string length.
...
11
votes
7answers
506 views
Class for handling unit conversions
I am creating a class to be the end all defacto class for handling unit conversions. This is particularly difficult in my company's industry where imperial architectural strings are used as units. I ...
1
vote
1answer
199 views
Milliseconds to Time string & Time string to Milliseconds
Fast Time conversion
I'm trying to write a very fast time-to-string and string-to-time function.
I noticed that on low CPU mobile devices this function has, even if minimal, impact on the ...
12
votes
3answers
321 views
Celsius → Fahrenheit conversion table
It's harder to do than criticize. Here's my attempt to implement a Celsius-to-Fahrenheit conversion table in C++.
...
5
votes
1answer
98 views
Convert a mediawiki to dokuwiki script
I have quickly wrote a Perl script to convert a mediawiki to a dokuwiki. I know there's an existing script to make that, but I would have a simpler usage code and some use of the API from mediawiki. ...
3
votes
1answer
51 views
Converting float from arbitrary base to arbitrary base
I needed to write a small program to convert floats from any base to any other base. The thing is, it got big. I know there are other ways to implement the conversions (such as doing subtractions ...
5
votes
2answers
235 views
Hex file converter
I have written a C# file reader that reads a file converts the bytes of the file to hex and writes it out to another file. It works fine but it takes 7.2GB of memory when converting a 300MB file.
...
6
votes
2answers
301 views
Number-to-word converter
My code works, but the aesthetic of the code seems to need some real work. The logic is simple enough: create three lists of words that will be used throughout the conversion, and create three ...
4
votes
1answer
131 views
5
votes
1answer
159 views
Converting between Fahrenheit and Celsius
I'm learning Ruby and working through some exercises. I completed the following exercise without truly understanding why and how it works. I know that's an embarrassing thing to say but I feel like my ...
6
votes
3answers
287 views
Binary string to integer and integer to binary string
I am working through K&R for review and I thought that I would write some of my own routines for conversion of binary strings to int and int to binary string. I realize this is reinvetning the ...
12
votes
7answers
687 views
Hexadecimal to integer conversion function
I am working through Kernighan and Ritchie to brush up on my C skills, so I thought I would invite critiques of my code.
Here is my Hex-to-int function:
...
5
votes
1answer
92 views
Function that converts file eol's
I've been unable to find a PHP function that will convert eol in files. This is what I have so far. It works, no errors.
Your educated opinions, thoughts, improvements, potential bugs and ...
10
votes
3answers
637 views
Is decimal, hexadecimal, octadecimal, binary converter efficient?
I have made a method which takes two parameters: the value to convert and the base. Based upon those two parameters my method is adjusted (with several helper methods) to change the desired decimal ...
2
votes
1answer
80 views
Refactor ConvertorToString class
Help me refactor this class that helps to represent an object state as String:
...
5
votes
1answer
49 views
Conversion from decimal to negabinary and vice versa in Haskell
Recently I set about to writing conversion functions in Haskell between decimal and negabinary. I tried to write them in as much functional a style as possible, also aiming at brevity. Below I present ...
5
votes
1answer
4k views
Converting List to a DataTable and/or DataSet Extension Methods
Can someone help me improve this code? I and trying to have a couple extension methods to convert strongly-typed lists to a DataSet and ...
6
votes
4answers
640 views
Function to convert ISO-8859-1 to UTF-8
I wrote this function last year to convert between the two encodings and just found it. It takes a text buffer and its size, then converts to UTF-8 if there's enough space.
What should be changed to ...
7
votes
3answers
234 views
Simple MPG calculator in Python
I am a self taught coder taking a Programming Fundamentals class to work towards a degree. It's based on Python, which I'm not as familiar with as other languages. I added error handling like I would ...
4
votes
3answers
83 views
4
votes
3answers
141 views
Number to words problem
This is a very long solution I've been working on to a Number to Words problem. I've identified that there's a lot of repeating logic (e.g. 'if writing > 0', 'writing = integer /',).
How would you ...
8
votes
3answers
348 views
Integer-to-string conversion using recursion
Adapt the ideas of printd to write recursive version of itoa; that is, convert integer into a string by calling a recursive ...
13
votes
5answers
2k views
Temperature conversion in C
I have started to learn C and I have tried my hand at temperature conversion. The idea is to convert a temperature from Fahrenheit to Celsius and vice/versa. Can somebody review my code and let me ...