Calculator programing problem

Associate
Joined
9 Sep 2009
Posts
1,266
If I've have these numbers and I they can be used or not (they relate to on off switches )
How can I write a program to work out which combination will get closest to a given number up to 128 ?


The letters are just there to label the switches

Thanks


64 A
32 B
16 C
8 D
4 E
2 F
1 G
0.5 H
0.25 I
0.125 J
0.0625 K
0.03125 L
0.015625 M
0.0078125 N
 
You can make every number exactly up to 128 with those combinations.
Your buttons relate to binary powers. Convert your target number to binary and that'll give you the answer...

(is this some sort of homework?)

Thanks, that's brilliant

Its not homework I'm trying to work out how to use some electronics.
 
You can make every number exactly up to 128 with those combinations.
Your buttons relate to binary powers. Convert your target number to binary and that'll give you the answer...

(is this some sort of homework?)
So I'm using Excel to convert to Binary DEC2BIn is there a way of showing numbers less than 0 ?
 
Back
Top Bottom