Click here to Skip to main content
15,918,041 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# Thread Pin
OriginalGriff26-Dec-22 1:02
mveOriginalGriff26-Dec-22 1:02 
GeneralRe: C# Thread Pin
Basel Shikh Osman26-Dec-22 1:06
Basel Shikh Osman26-Dec-22 1:06 
GeneralRe: C# Thread Pin
OriginalGriff26-Dec-22 1:14
mveOriginalGriff26-Dec-22 1:14 
GeneralRe: C# Thread Pin
BillWoodruff26-Dec-22 2:50
professionalBillWoodruff26-Dec-22 2:50 
AnswerRe: C# Thread Pin
Gerry Schmitz26-Dec-22 8:16
mveGerry Schmitz26-Dec-22 8:16 
QuestionUpdating properties in a IEnumerable Pin
hpjchobbes24-Dec-22 4:14
hpjchobbes24-Dec-22 4:14 
AnswerRe: Updating properties in a IEnumerable Pin
Gerry Schmitz24-Dec-22 6:35
mveGerry Schmitz24-Dec-22 6:35 
GeneralRe: Updating properties in a IEnumerable Pin
hpjchobbes24-Dec-22 9:58
hpjchobbes24-Dec-22 9:58 
GeneralRe: Updating properties in a IEnumerable Pin
Gerry Schmitz24-Dec-22 23:48
mveGerry Schmitz24-Dec-22 23:48 
GeneralRe: Updating properties in a IEnumerable Pin
BillWoodruff25-Dec-22 5:04
professionalBillWoodruff25-Dec-22 5:04 
AnswerRe: Updating properties in a IEnumerable Pin
Mycroft Holmes24-Dec-22 11:09
professionalMycroft Holmes24-Dec-22 11:09 
Generalc# Pin
Member 1587460624-Dec-22 3:18
Member 1587460624-Dec-22 3:18 
GeneralRe: c# Pin
OriginalGriff24-Dec-22 4:06
mveOriginalGriff24-Dec-22 4:06 
GeneralRe: c# Pin
BillWoodruff24-Dec-22 18:39
professionalBillWoodruff24-Dec-22 18:39 
GeneralRe: c# Pin
OriginalGriff24-Dec-22 19:44
mveOriginalGriff24-Dec-22 19:44 
GeneralRe: c# Pin
RedDk25-Dec-22 6:30
RedDk25-Dec-22 6:30 
GeneralRe: c# Pin
OriginalGriff25-Dec-22 21:44
mveOriginalGriff25-Dec-22 21:44 
GeneralRe: c# Pin
Nitin S26-Dec-22 18:10
professionalNitin S26-Dec-22 18:10 
GeneralRe: c# Pin
RedDk27-Dec-22 8:54
RedDk27-Dec-22 8:54 
Questionconvert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
Sakhalean23-Dec-22 23:48
Sakhalean23-Dec-22 23:48 
AnswerRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
OriginalGriff24-Dec-22 0:29
mveOriginalGriff24-Dec-22 0:29 
GeneralRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
Sakhalean25-Dec-22 4:52
Sakhalean25-Dec-22 4:52 
AnswerRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
BillWoodruff24-Dec-22 18:37
professionalBillWoodruff24-Dec-22 18:37 
GeneralRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
Sakhalean24-Dec-22 22:46
Sakhalean24-Dec-22 22:46 
GeneralRe: convert double with decimal places to any base in C# example : 19.879 to any base or -19.345 to any base Pin
trønderen24-Dec-22 23:13
trønderen24-Dec-22 23:13 
BillWoodruff wrote:
ask yourself what numeric types it makes sense to convert the values you describe
Why wouldn't it make sense? If b >= 10, you obviously have to define 'digits' for 10+; using A-Z for 10-36 is quite common. Equally obvious: The result of conversion must be treated as a digit string; there is no other way to handle, say, a base 13 number in a binary computer.

In decimal, the digits to the left of the decimal point give the number of ones, then number of tens, then ten**2s, ten**3s, ten**4s, ... To the right of the decimal point digits give the number of 1/10s, then the number of 1/(10**2)s, 1/(10**3)s, 1/(10**4)s, ...

For base b, the digits to the left of the point give the number of ones, then number of bs, then b**2s, b**3s, b**4s, ... To the right of the point, digits give the number of 1/bs, then the number of 1/(b**2)s, 1/(b**3)s, 1/(b**4)s, ...

I guess it would be somewhat confusing to call it a decimal point, though.

"Octal is just like decimal ... if you are missing two fingers" (Tom Lehrer)

To the OP: I would have split the number on the point, treating the whole and the fractional parts separately, converting then to binary integers, and then iterated each over a divide/remainder down to zero. Note that for the fractional part, you must set a reasonable limit for the number of digits - in, say, base 13 you cannot represent 879/1000 (that is from your first example) as any finite series of fractional digits f1/13 + f2/169 + f3/2197 + ... + fn/(13**n), except for a few special cases. (That goes for decimal .879 or .345 as well; they are not represented by those exact values in double format.)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.