Questions tagged [converting]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
41 views

Convert dict to array in Python [closed]

I have a dictionary that looks like this: Counter({(1, 9): 3, (4, 2): 2, (3, 0): 1, (5, 4): 1}) I would like to convert it to an array that would look like this: ...
11
votes
8answers
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) ...
3
votes
0answers
26 views

Instant to-and-from Roman Numeral Conversion

Ⅰ Roman numerals are composed of digits taken from a small set of uppercase characters. Lowercase characters were first used in the Middle Ages. $$I,V,X,L,C,D,M$$ With these digits we can ...
1
vote
1answer
56 views

Image type convertion

So I have a piece a code that, altough it does what is expected, it doesn't seam very performant to me. I just wanted to know if there's a better way to do this or if my code is alright as it is. The ...
4
votes
1answer
101 views

fasm convert hex byte to binary string

This fasm x64 (Linux) code seems very crude and repetitive, but it gets the job done. How could I perform this task in a more idiomatic manner? ...
5
votes
1answer
143 views

process numerical input arguments of mixed ints, floats, and “array-like” things of same length>1

I'm trying to process numerical input arguments for a function. Users can mix ints, floats, and "array-like" things of ints and float, as long as they are all length=1 or the same length>1. Now I ...
5
votes
1answer
169 views

Normalizing mixed format nested dictionary with delimiter separated keys

I recently worked with some pickle files which had a really strange format where the keys are sometimes delimiter separated with colons and placed in the same depth but also mixed with ordinary key ...
2
votes
1answer
78 views

Convert char array to number

C++17 have <charconv>. However this header does not work on MacOS - It compiles, but can not link. Same header is not present in ...
-1
votes
1answer
126 views

Naming convention when converting between types? [closed]

If I have a method where the input is a list of integers, and within that method I convert the list to a list of strings, what is the best way to name the new list? For example (using ...
5
votes
2answers
927 views

Sum of all digits in a string

Given a string, return the sum of all the numbers in the string, 0 if none are present. Below is my solution for the problem above. I feel like this can be turned into one line. I would really only ...
6
votes
1answer
73 views

Convert a Hex value string to an ASCII Text String

We had a little bit of fun in the 2nd Monitor this morning, one user greeted another with a hex string. It turned out that the user being greeted deals with Hex Dumps enough that they were able to ...
7
votes
4answers
211 views

Code that reads/writes to bytes of an ascii-encoded hex string

Problem Statement Given a hexadecimal string (hascii) and its binary specification (a list of byte field names, their offsets, and byte lengths), design classes to parse all byte-fields, cast bytes ...
3
votes
1answer
63 views

Constructing constrained/validated objects

I'm trying to do some rudimentary DDD in validating my objects to ensure they are of a particular type. I.e. an Email object would always look like "my@example.com" ...
4
votes
1answer
252 views

Converting a binary string to hexadecimal using Rust

Once again, I am reinventing the wheel here to understand the fundamentals of rust. In a previous question I requested feedback on my function that performed a hexadecimal to binary conversion. In ...
5
votes
1answer
137 views

Converting a hexadecimal string to a binary string using Rust pattern matching lookup

I am getting started in Rust, and as a part of my first exercise, I decided to write a small program that converts a hexadecimal string to a binary string using a pattern matched lookup. I would ...
9
votes
1answer
143 views

Convert to dictionary

Earlier I did post with full code about Prepare and export data to MS Word file. The user t3chb0t recommended me to separate some part of full code to this post. Context The task of code for review ...
3
votes
1answer
87 views

Convert a Binary Tree to Doubly Linked List

Challenge Link on geeksforgeeks: Binary Tree to DLL Given a Binary Tree (BT), convert it to a Doubly Linked List(DLL) In-Place. The left and right pointers in nodes are to be used as previous ...
4
votes
2answers
117 views

Converting a set into a string

The input is a set of alphabets. The output is a string of 32 in length. For any letter in the set if it is preceded by a '¬' we replace the n-th character in our output string with '0', such that n ...
7
votes
3answers
258 views

Convert HTML color to OLE

I have this function that takes a string which represents a html-color and returns the OLE value for it. If the string is null or empty or it can't be parsed, it uses a default value. However I have ...
1
vote
1answer
84 views

Format the output of Color.ToString() to RGB values [closed]

The method that I wrote below functions properly; however, I believe that the code I wrote is not clean nor "good". I know the basics of regex but I do not know more advanced techniques as I am still ...
2
votes
1answer
85 views

Static Methods for Dealing with Conversions from and to UTC

I asked this question over at stackoverflow but was told it may be better suited here. So I absolutely want to store DateTimeOffset objects in UTC format. To ...
3
votes
2answers
41 views

Excel To CSV Converter Ch 9 ATBS

I am learning more about python using the book "Automate The Boring Stuff". The problem I completed was "Excel To CSV Converter". I want to kick bad habits to the curb, and make sure I'm learning the ...
2
votes
2answers
64 views

Dephi: faster way to convert a “dirty” string to a number

How can I make this code faster? the string can contain characters such as ", .?#" and possibly others. ...
6
votes
2answers
201 views

Internal and external datatype converter

One of the big problems I have is cleanly converting from an internal datatype to an external datatype. We can all do it the not so clean way, however I think this add too much mess. I can use ...
4
votes
1answer
45 views

Get local datetime from UTC time

One of the app is inserting date in UTC format (column CreateDate). When reporting from this table, I used a difference in hours between the inbuilt ...
3
votes
1answer
436 views

Convert *.VCF contact file for cellphone import

My new mobile phone is capable of importing contact information from a renamed *.VCF file stored on an SD memory card (https://www.quora.com/How-do-I-sync-contacts-on-Nokia-130). Annoyingly, it does ...
10
votes
5answers
15k 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 ...
2
votes
0answers
52 views

String to long double conversion using FBLD

I always wanted to try fbld x87 instruction to aid to convert string to floating point value. I sure a chance to face this instruction in disassembly of all the ...
4
votes
2answers
473 views

Convert data frame to list of lists by row

I am rewriting some old code where I take a dataframe in r and convert it using the tidyverse packages to a list of lists, where ...
2
votes
4answers
166 views

Taking 2 command line inputs and verifying that they are integers, within the correct range of values

I'm taking 2 command line inputs, which have to be integers between 2 and 1,000,000. These two values are then passed into the getPrimes function, which is just a ...
2
votes
0answers
84 views

Converting between bases (2 to 221) with optional seeds and padding

It's been a while since I had a bit of fun getting something useless working, so I thought I might as well ask if there's anything to improve about how I do things. The original idea was to convert <...
3
votes
1answer
5k views

Generate JSON File from a given YAML file

I'm didn't use java for a long time(5 years ± ) and in the following code the user should provide yaml file and it converting it to json file. The code is working as expected but since I didn't use ...
4
votes
1answer
730 views

constexpr Endian conversion in c++14

This is my take for constexpr big / little endian conversions. The code supports only little and big endian; mixed endian such PDP is not supported. ...
8
votes
2answers
3k views

Convert mixed-format phone numbers to pure numbers

I am just getting started with C# and wanted to make sure that I am aware of any errors/inefficiencies in my code. For this specific project, I wanted to prove to someone that a "bot" could easily ...
2
votes
0answers
419 views

Convert FoxPro/dBase DATETIME field to Win32 SYSTEMTIME struct

I'm trying to write a complete driver for Visual FoxPro's DBF format for Win32. I found that the way that fields of the DATETIME type are stored in dBase files is ...
4
votes
3answers
291 views

Converting from decimals to roman numerals

I've submitted the following code for a job interview, and I wanna know if there is anything I can improve on it, or better ways to do the same thing. ...
4
votes
1answer
191 views

Extending COERCE to other reasonable object type conversions

It's a basic principle in AI that different problem representations can either facilitate or impede a solution. Being able to readily switch data representations while programming in Common Lisp may ...
2
votes
0answers
101 views

ByteUnit class to convert across size units

Based on java.util.concurrent.TimeUnit class I wrote similar class to convert size units: ...
1
vote
1answer
2k views

Hex-string representation of a byte array [closed]

I have a legacy method toHex(byte[]) used in my application since the beginning of time to store a hexadecimal representation of a ...
5
votes
5answers
828 views

Enum with a lot of items and a long case statement to convert from string

Recently I wrote this class and it has a enum of all the interaction types a game item can have. What I want to know is, it seems a bit of a stretch to have a huge enum then that long switch, is there ...
0
votes
2answers
16k views

Interpret YYYYMMDD as the nth day of the year [closed]

I am provided a bunch of dates in the format (YYYYMMDD) such as: date='20170503' My goal is to convert that date into the ...
5
votes
2answers
3k views

Using generic types for a custom mapper

I have a method which takes a certain generic object, which basically orders these objects based on a list of tags. Because I want to use this method for multiple objects, I have created a class which ...
4
votes
3answers
191 views

Setting Entity Framework up for success

So I am working on an application (top-secret!) that I need settings for, these settings are pretty basic, but I don't want to make a single-row table with a bunch of serialized settings, or a single-...
1
vote
1answer
581 views

C++ conversion from std::string to arithmetic type using std::locale::classic()

I recently had a bug where extracting a decimal from a string failed due to locale settings. That is, some locales use a , as a decimal point, rather than a ...
11
votes
2answers
541 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 ...
2
votes
0answers
842 views

Converting [UInt32] -> [UInt8] -> [[UInt8]]

I am trying to speed up my current implementation of a function that converts [UInt32] to a [UInt8] which in turn is split up ...
2
votes
2answers
229 views

Pronounceable binary-to-text encoding

This is a binary-to-text encoder that is based on Base64, but it works by converting data into an almost pronounceable string (consonant-vowel-consonant-vowel for each 3 bytes). Any improvements, ...
0
votes
1answer
2k views

Construct: bytes and bits conversion

This code is part of Construct library that converts between byte and bit representations. ...
3
votes
1answer
76 views

Map object types using custom converter

I'm trying to design a mapper that will convert one object type to another shown in the diagram below: The object has structure as follows (it's not a JSON): ...
4
votes
1answer
15k views

Convert an image to 8-bit color

I have a function that will take an image and then return that image in 8-bit color. Almost all of the code was taken from MSDN. The code is quite short compared to all of the other methods I've seen ...

1
2 3 4 5
7