Converting involves changing data from one data type or format to another.

learn more… | top users | synonyms

5
votes
1answer
60 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 ...
9
votes
3answers
286 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 ...
-1
votes
0answers
19 views

Converting hex/binary array to string array [closed]

In my quest to be better at programming, I've stumbled upon something that I just cannot answer. I was tasked to convert binary/hex data (in an array) to string array. So far I've only managed to ...
2
votes
1answer
72 views

Refactor ConvertorToString class

Help me refactor this class that helps to represent an object state as String: public class ConvertorToString { private static final String SEPARATOR_BETWEEN_FIELD_NAME_AND_VALUE = "="; ...
5
votes
1answer
32 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
112 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 DataTable respectively. But... being so green to C#, I am not ...
6
votes
4answers
293 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
132 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
58 views

Mutual conversion operators

What is more readable? value / 60 / 60, value / 3600, or Hours{static_cast<Minutes>(*this).value / 60}? Should I use constants, i.e. SECONDS_IN_HOURS. Should I use the explicit keyword? Would ...
4
votes
3answers
55 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 ...
7
votes
3answers
101 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 routine Here is the implementation of printd: void printd(int n) { ...
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 ...
7
votes
2answers
111 views

Digit to words converter

This is one of the longest programs I have made with methods and I think I must be doing this rather inefficiently. Any comments to improve would be appreciated. package numberwords2; import ...
3
votes
1answer
54 views

Is this base 62 encoding algorithm okay?

This Scala code snippet is supposed to encode a SHA1 hash in base 62. Can you find any issues? I'm asking since I might not be able to change the algorithm and, for example, fix issues in the future. ...
9
votes
4answers
262 views

Type system for different representations of angle value

I want to implement a Type system for different representations of an angle value. Motivation to implement this as a type system comes from this question. Angle can be represented using the ...
1
vote
1answer
60 views

Python converter: number-to-English

So I wrote this function to convert a given number to its interpretation in the English language as part of the Project Euler exercises. It works fine, but I sense that it's rather sloppy and ...
3
votes
1answer
114 views

Convert between date/time and time-stamp without using std library routines

I am trying to implement in C two simple convertors, date/time to time-stamp and vice-versa, without any dependencies on time library routines (such as localtime, mktime, etc, mainly due to the fact ...
14
votes
2answers
277 views

Simple temperature converter

Below is my first attempt at programming a Celsius to Fahrenheit converter in C# winforms. I'm looking for tips and advice on improving my style and what I can do to make the code more ...
2
votes
3answers
325 views

Convert Sql LIKE to Regex

I have a bit of code that converts a Sql Like expression to a regex expression for the purposes of a Linq to objects Like extension method. For some time I have been using this conversion. This ...
2
votes
3answers
147 views

Number to Roman Numeral

var romanArray = []; var toRoman = { analyze: function(number){ romanArray = []; if (number >= 1000) { return this.thousands(number); }else if (number >= ...
-1
votes
2answers
907 views

Code review: infix to postfix converter [closed]

public static StringBuffer infixToPostfix(StringBuffer infix) throws InvalidCharacterException { StringBuffer postfix = new StringBuffer(""); Stack<String> myStack ...
3
votes
2answers
127 views

Roman numerals to decimal

This is an assignment for class. I would like to know how to improve my code. It is a program to convert Roman numerals to it's decimal equivalent. This is what I have so far. There must be a better ...
5
votes
4answers
177 views

Converting std::string to int without Boost

I'm trying to convert an std::string to an int with a default value if the conversion fails. C's atoi() is way too forgiving and I've found that boost::lexical_cast is quite slow in the case where the ...
3
votes
2answers
145 views

Roman numeral converter in Ruby

For a Project Euler problem, I made a Ruby roman numeral converter: def romanize(num) digits = { 1000 => "M", 900 => "CM", 500 => "D", 400 => "CD", 100 => "C", ...
0
votes
3answers
85 views

Need help optimizing/making this code more efficient

So I'm working on a code where it converts shoe sizes and distance public class ConvertValuesAndCalculate { final String BASE_UNIT = "centimetres"; double distance, shoeSize; String ...
5
votes
3answers
191 views

Organization of measurements converter

I am pretty new to Python but I'm learning from classes. I am working on a project for class and this is my code. Anyone got a better idea of a way to organize the code or put it differently so there ...
2
votes
1answer
240 views

Converting looped row in table from datetime to string [closed]

I am trying to pull out the whole column for row[3] in the following script. Everything works, but unfortunately, the code is only pulling out the last row's data from the whole page while everything ...
2
votes
1answer
6k views

Faster way to convert DataTable to List of Class

I am using ExcelDataReader to import an excel file to a dataset. Example Excel table below: //ID Name Display Order Active //1 John 1 1 ID, DisplayOrder and ...
5
votes
1answer
88 views

YouTube-to-Spotify converter

I have been doing some JS lately and I would like to get some constructive criticism. The project I am working on Live demo var SpotifiedList = [], youtubeSongs, spotifySongs = 0, spotifiedSongs = ...
2
votes
2answers
965 views

Conversion of expression from Prefix to Postfix notation (Problem with precedence) [closed]

I have been attempting to write a code that converts Prefix expressions to Postfix expressions. So far here's what I have made (note that I am new and hence it may not be efficient!) ...
4
votes
1answer
130 views

Currency converter

I'm just looking for someone to give a critique of my currency converter. I want to see if I could clean it up first before dummy-proofing. I know you want to avoid floating types for working with ...
5
votes
1answer
249 views

Writing the Word Equivalent of a Check (Cheque) Amount

I am looking for feedback on a solution to the following problem posed from a book that I'm working through (Java: How To Program 9th Edition) :- Continuing the discussion in Exercise 16.20, we ...
0
votes
3answers
287 views

Converting a c# enum into a list to be sent to the client

I want to use the enum on the client for a dropdown list. Does this make sense, or is there a smarter way of doing this? public class clientEnum { public string Value { get;set;} public int ...
4
votes
1answer
757 views

Improving my floating-point binary/decimal/octal/hex converter

I've finally decided to design a class for this program, but some of the code still looks messy. I'm also a bit concerned about DRY, particularly in binaryToOctalHex(). The program is looking ...
2
votes
4answers
212 views

Cleaner and/or more practical code for decimal/binary/hex converter

I've finally finished my converter and have determined that it works, but I'm trying to make it cleaner and/or more practical (primarily with the switch statements). I could probably put more things ...
6
votes
2answers
381 views

Converting Roman numerals to decimal

Could someone please point out the error(s) in the given code? It was downvoted on Stack Overflow without any explanation, but it seems to be working fine for me: int value(char roman) { ...
5
votes
1answer
100 views

Char* hex string to BYTE Array

The idea is that i want any size string to put the corresponding hex value into a byte array. I've seen a million ways to do it. Some of them didn't look to clean. My needs are speed over memory, so ...
2
votes
1answer
115 views

Implement numbering scheme like A,B,C… AA,AB,… AAA…, similar to converting a number to radix26

I want to implement numbering scheme like Microsoft Word uses for numbering. first one gets = A,next is B, next is C, .... then AA, then AB,....and so on. as shown below A B C . . AA ...
7
votes
3answers
3k views

Roman Numeral to Decimal Conversion

I'm mostly looking to get feedback on how well I've implemented the C++ language. But I would also like feedback on my algorithm. Did I make it more complex than it needs to be? Is there anything I ...
1
vote
0answers
53 views

Date and time columns conversion to Time(WithZone)

I got 2 columns representing a date and a time. {dateproc: '2012-03-23', horproc: '2000-01-01 16:15:23 UTC'} Both are read as a TimeWithZone by rails. I need to combine them. This is what I've ...
1
vote
1answer
191 views

Help me improve my attempt to slap strong types on top of COM and ODBC

I am stuck with some old API that involves COM and ODBC, and I cannot switch to cool things like MEF or entity framework. So, I am working on some wrappers that will help me write less code and also ...
1
vote
4answers
145 views

Converting hex character to decimal

Is it possible to make this code more efficient & elegant? int HexToDecimal(char ch) { ch = tolower(ch); if ('a' <= ch && ch <= 'f') { return ch - 'a' + 10; ...
6
votes
4answers
381 views

Converting an integer into the written form

For my homework assignment I have to create a class which converts an integer between 0 and 9999 into the written form. For example, 713 would be written as "seven hundred thirteen." I wrote a few ...
3
votes
3answers
716 views

Best C# idiom to convert the items on an object array to a string?

I have something akin to object[] values = getValues(); string renderedValues = string.Join("-", Array.ConvertAll<object,string>(values, new ...
7
votes
1answer
4k views

Converting binary value from BitArray to an int and back in C#

What I am creating is essentially a binary clock face with touch input for setting values as well as displaying - so I need to convert both ways between an int and a binary sequence in a BitArray. I ...
2
votes
1answer
1k views

Javascript conversion of datetime strings in PHP pages to user's timezone

I am working on an PHP/MySQL application that uses a different timezone from the server it runs on, and neither of the timezones are UTC. I'm converting displayed times to be in the user's timezone, ...
9
votes
3answers
561 views

Simple text-to-binary converter written in C++

I am learning C++ on my own and was hoping for some feedback on this simple text-to-binary converter. The program runs and I haven't encountered any errors with it yet. Any input is welcome. ...
11
votes
3answers
349 views

Brainfuck to C converter

This program converts Brainfuck source code to C and compiles it with gcc. It runs very well (that was my first time I played Lost Kingdom), however, the code is quite long because some parts are ...
5
votes
1answer
3k views

Conversion from/to roman numbers

I wrote as an exercise in Test-Driven Development a piece of Python code that contains two functions: roman2dec(roman), that converts a roman number (string) into a decimal number (int) ...
16
votes
11answers
20k views

Converting between std::wstring and std::string

While researching ways to convert back and forth between std::wstring and std::string, I found this conversation on the MSDN forums. There were two functions that, to me, looked good. Specifically, ...