Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,560

Have been rewriting my Binary/Decimal/Hexadecimal Converter from the ground up, using my "Full Precision" library.

Can you guys throw some different numbers at it to see how it performs?

Binary/Decimal/Hexadecimal Converter - Test Version

Let me know any oddities, cheers!

"The physicists defer only to mathematicians, and the mathematicians defer only to God ..." - Leon M. Lederman

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 95,975

Hi MIF;

So far it looks pretty good.

**In mathematics, you don't understand things. You just get used to them.**

**If it ain't broke, fix it until it is.**

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,560

Excellent ... so far

"The physicists defer only to mathematicians, and the mathematicians defer only to God ..." - Leon M. Lederman

Offline

**bob bundy****Moderator**- Registered: 2010-06-20
- Posts: 7,020

hi MathsIsFun

Tests out OK so far for me; whole, fractional and negative.

Bob

You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei

Offline

**ganesh****Moderator**- Registered: 2005-06-28
- Posts: 17,004

Hi MathsIsFun,

The binary/decimal/hexa-decimal converter works very well!

Excellent, MathsIsFun!

Character is who you are when no one is looking.

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,560

Thanks.

Any suggestions for improvement?

I had someone email me asking for leading zeros, but it may look OK having 0010 as a binary, but what should that be as a decimal? 02? 002?

"The physicists defer only to mathematicians, and the mathematicians defer only to God ..." - Leon M. Lederman

Offline

**bob bundy****Moderator**- Registered: 2010-06-20
- Posts: 7,020

Leading zeros:

That depends on what the user wants from the conversions. I'd have thought that spaces to make a fixed 'byte' size might be more useful; thus:

0011 0101

234 567.234 456

FFFF FFFF

0001 0101.1111 1100

023 456 789.123 456 789

000F ABCD 1234.FFFF 6767 6700

So pad out the bin and hex to blocks of 4 with zeros front and rear and the decimal in similar blocks of 3.

btw. These are 6 independent examples not 2 with conversions.

Bob

You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 95,975

Hi MIF;

Maybe here is a good spot to indicate to the user a strange phenomenon that occurs in programming more than in mathematics.

If you enter .5374 in decimal you get

and

This might suggest that is the exact answer. If you carry more digits you get

and

(Pardon the lowercase letters, Mathematica thinks they are not worthy of Capitalization.)

You can continue this process because although .5374 terminates in base 10 it may not in other bases. For instance, 1 / 10 is .1 in base 10 but is non terminating in base 2. An ellipsis ... could be put to suggest that there are more digits.

**In mathematics, you don't understand things. You just get used to them.**

**If it ain't broke, fix it until it is.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,922

Hi MIF

The converter shows strange behavior when I try to put in "1.2." in the hexadecimal box with a dot after the 2. The output is okay for the binary number, but it is weird for the decimal conversion. Maybe you should just disallow adding 2 dots altogether. The same goes for "e". Adding e's after the first changes the results.

There should also be a way to enter recurring decimals.

Otherwise, it is a very nice piece of work (like every other Flash "app" you made ).

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,560

A new test version needs testing: Binary/Decimal/Hexadecimal Converter - Test Version

I often get contacted by people who confuse "computer binary" (limited bits), with treating a binary number as a number. They insisting that "-1 decimal" should be "11111111 binary" (with the first bit being a sign bit), so I have tried to satisfy all comers with a drop-down box of common types.

The trouble is that it opens up many possible errors, so could you kind folk try out lots of things and tell me if they work for you?

Consider:

* positive/negative

* fractional values (like 1.1)

* changing binary, decimal or hex value

* as a number/8-bit/etc.

Cheers!

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 95,975

Hi MIF;

What is the difference between the menu item 0001 and number?

**In mathematics, you don't understand things. You just get used to them.**

**If it ain't broke, fix it until it is.**

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,560

0001 is supposed to pad binary with zeros to make groups of 4 (so it matches hex)

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 95,975

Hi;

So far the signed 8 bit is working fine. Doing more testing of the others.

**In mathematics, you don't understand things. You just get used to them.**

**If it ain't broke, fix it until it is.**

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,560

Thanks for that.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 95,975

Hi;

It will take some time with the 16bit signed integers and fractions.

**In mathematics, you don't understand things. You just get used to them.**

**If it ain't broke, fix it until it is.**

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 95,975

Hi MIF;

Are you using a two's complement for your negative numbers?

**In mathematics, you don't understand things. You just get used to them.**

**If it ain't broke, fix it until it is.**

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,560

Yes, I believe that is the standard in computing.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 95,975

Hi;

Everything working all the way to the signed 32 bits for integers. Will keep checking and then to decimals.

I am fairly confident in the results except I have not checked negative signed 32 bit floats.

**In mathematics, you don't understand things. You just get used to them.**

**If it ain't broke, fix it until it is.**

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,560

That is really kind of you, thanks.

So it is nearly ready to go live (and replace the existing one).

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 95,975

Hi;

I would like to try one more thing but I will require your help. I can not find a good description of the implementation of signed 32 bit for floats like 45.567 etc. I am using everything left of the rightmost bit is inverted. Can you explain yours?

**In mathematics, you don't understand things. You just get used to them.**

**If it ain't broke, fix it until it is.**

Offline