Questions tagged [converting]

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

Filter by
Sorted by
Tagged with
46
votes
2answers
248k views

Converting DataTable to List of class

I am using ExcelDataReader to import an Excel file to a dataset. Example Excel table: ...
40
votes
9answers
104k 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 ...
33
votes
2answers
109k views

Integer to Alphabet string (“A”, “B”, …“Z”, “AA”, “AB”…)

So this question is prompted by two things. I found some code in our source control doing this sort of things. These SO questions: https://stackoverflow.com/questions/297213/translate-an-index-into-...
25
votes
5answers
35k views

Use of a regex stored inside a YAML file

I installed settingslogic and in the configuration file I put the regex for the email as follows: ...
25
votes
6answers
98k views

Conversion between enum and string in C++ class header

I have the following redundant-feeling design to convert between enums and strings regarding a class that stores enums. The ...
24
votes
4answers
76k views

Convert Object to a DateTime

...
21
votes
3answers
4k views

Converting from polar coordinates to rectangular coordinates

This is performance critical. I measured and determined that using the sqrt is faster then using the cos method. I am aware ...
16
votes
4answers
26k views

Integer seconds to formated string mm:ss

I have a String like "Time left (XX)" or "You need stay here for (XX)" and int as second. I use those two variables to format ...
16
votes
2answers
14k views

Convert Persian digits to English numbers

I use the following code to convert ۱۲۳۴۵ to ‍12345, effectively transliterating the persian numbers into latin numbers: ...
16
votes
2answers
6k 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 efficent/proper,...
15
votes
2answers
35k views

cm-to-inch calculator

After a few pages reading Learning Python Hard Way, I've decided to try to make a simple cm-to-inch calculator. I am very excited about this achievement, and I want someone to check my code. It works ...
15
votes
7answers
13k 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: ...
15
votes
2answers
11k views

Roman numerals to decimal

This is a program for converting Roman numerals to their decimal equivalents. There must be a better way of distinguishing between, for example, 'IV' and 'VI', than what I have currently written. <...
15
votes
4answers
2k views

Number to words in left to right direction

I have faced this 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 then the ...
14
votes
5answers
4k 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 ...
14
votes
2answers
83k views

Introductory Currency Converter

This is my basic currency converter for my intro to Java class. I'm supposed to be able to convert between Yen, Dollars, Pounds and Euros using static rates. It works, but I was curious to know if I ...
14
votes
3answers
1k 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 ...
14
votes
3answers
13k 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. ...
14
votes
2answers
3k views

Returning result and error status for number type conversions

Looking for review of design strategy of using a struct to return the functional result and error status. Your experience of how my design approach may succeeded ...
14
votes
2answers
34k views

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

I am trying to implement two simple convertors: date/time to time-stamp and vice-versa, without any dependencies on time library routines (such as localtime, ...
14
votes
2answers
19k views

Converting Roman numerals to integers and vice versa

...
14
votes
2answers
3k views

Boost Python converter for std::tuple

I could not find a Boost Python converter which converts std::tuple, so I wrote one. This was tested with a g++ 4.7 snapshot on Debian squeeze. It uses C++ 11 ...
13
votes
6answers
10k views

Converting strings to PascalCase

I have a method which I use on occasion to convert strings (like enum and property names) to PascalCase for display. It's ...
13
votes
1answer
285 views

Naming numbers in American English

This seems like a popular topic lately, so I took a crack at it. Related questions are Number to Words and Converting a number to the text representation. I used this article as a guideline. The ...
12
votes
4answers
3k 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 ...
12
votes
2answers
512 views

Application for converting markdown to PDF

First time writing C in a long time and would like some code review to try and improve my code. I have some specific questions, but first an introduction to the code. The application is a simple ...
12
votes
7answers
12k 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 ...
12
votes
3answers
1k views

Binary Converting Code

I made a program that converts a decimal number given from the user, and converts it to a binary number. For example, if I entered 2, it would return 10. It then, counts the amount of ones and zeros ...
12
votes
1answer
26k 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 ...
12
votes
2answers
7k views

Conversion Between Units

I have created a java program that should take a list of conversions and be able to convert one unit to another. My main goals are maintainability and readability, but speed would be nice as well. ...
12
votes
3answers
8k views

SQLConnect - A library for connecting Objective-C/Swift applications to Microsoft SQL Server

The complete SQLConnect library can be found here. The file from which the following method belongs can be found here. At some point I may or may not open questions for reviewing other aspects of ...
12
votes
1answer
5k views

Roman Numerals in Java

I wrote a class that can convert to and fro from Roman Numerals and Decimals. I would appreciate critical points on everything, especially: Shortening my code. Choosing a better approach. Using ...
12
votes
1answer
4k 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 type....
11
votes
6answers
3k views

Program that converts a number to a letter of the alphabet - follow-up

This is a follow up from my previous post: Program that converts a number to a letter of the alphabet This is meant to teach my little brother (who only knows how to make games in Geometry Dash) ...
11
votes
6answers
20k views

12 hours to 24 hours conversion function

I have made a time format converter which converts 12 hour format to 24 hour format. My convert_to_24() takes a string in format of ...
11
votes
2answers
2k views

Converting to Base 26 in One Based mode

I needed to create a simple method that converts numbers in Base 26 (string) using, as expected, letters from a to z. But that's not all, this Base 26 needs to be ...
11
votes
2answers
573 views

A Binary Editor with Live Text Preview

This is a tool I needed for some other things (it's incomplete, but almost done) which is essentially just a text-editor that has two text-boxes: the left being the binary view / raw bytes, the right ...
11
votes
1answer
5k views

Convert WKT representations of geometries into GeoJson

I am working on a class library in C# to convert WKT to GeoJson. I am getting shapes in WKT out of MSSQL. A lot of the shapes ...
10
votes
3answers
28k views

Function that convert decimal to binary

I have a function that converts an integer to its binary representation. I am wondering if there is any way I can improve the function. ...
10
votes
4answers
11k 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 ...
10
votes
5answers
20k views

Convert a custom object to a query string

I wrote an extension method that takes a custom object and converts its properties to a query string for use in a URL. You can specify what properties you want included by using a ...
10
votes
4answers
47k views

Converting the DateTime to and from Unix epoch times

I'm currently working on a thing I needed this feature for. Essentially, these are two methods to convert DateTime objects to and from the Unix epoch time (two ...
10
votes
2answers
905 views

Numbers to words converter

Please review my code: ...
10
votes
3answers
795 views

Beginnings of a base-conversion game in Python

I'm pretty very new to python, so I thought that I'd write a game to teach me python and better teach me how to think in hexadecimal and binary. I'm starting off by writing a few functions to convert ...
10
votes
3answers
3k 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 ...
10
votes
2answers
2k views

Number to Words

I have to convert positive numbers, that are less than 1000, to words. A quick search didn't find anything that looked good to my eye, so I came up with the following. While I was at it I expanded ...
10
votes
1answer
807 views

Spell a given number in English

I wrote a program that will take a number from 0 to 999,999,999,999 and spell out that number in English. How could I improve the readability of my code? ...
10
votes
3answers
22k 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 Create three functions: ...
10
votes
1answer
7k 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 ...
10
votes
1answer
5k views

Converting a range of integers from a string to an IEnumerable

Goal Convert the following into an IEnumerable of integers accounting for the x-y ranges: ...

1
2 3 4 5
7