flat assembler
Message board for the users of flat assembler.
  
|  Index
      > DOS > Summation Program | 
| Author | 
 | 
| rhyno_dagreat 21 Oct 2006, 23:23 I have created a small summation program which will take n amount of numbers and do the summation 1+2...+n. It is only single digit for now (mainly because I don't know how to make a multidigit decimal number from ascii, and vice versa.) Anyways, here it is! Enjoy    ! 
 | |||||||||||
|  21 Oct 2006, 23:23 | 
 | 
| Sebastian R. 26 Oct 2006, 10:23 Somehow it only works for 1 - 3. If I enter 4, 5 ... it displays some characters. | |||
|  26 Oct 2006, 10:23 | 
 | 
| rhyno_dagreat 27 Oct 2006, 02:32 Sebastian, it gives you a domain for what the input can be in the program.   Read the first thing that pops up when you run it. | |||
|  27 Oct 2006, 02:32 | 
 | 
| Sebastian R. 27 Oct 2006, 10:01 Yes, sorry, now I can see it. ^^ | |||
|  27 Oct 2006, 10:01 | 
 | 
| Madis731 27 Oct 2006, 10:45 A few things you could do:
 the sum of numbers 1 to N is ((1+N) * N) shr 1 The 1,2 and 3 are too little of a set to make a point. You could at least hardcode it to accept 2-digit numbers. The output could also be multidigit. That is why its problematic (or even erratic) when tested now. EDIT: My try on the program EDIT2: Yeah I new the formula was wrong, but the program was correct. I didn't just correct it yet. Now also the formula given above is corrected. 
 Last edited by Madis731 on 28 Oct 2006, 09:35; edited 1 time in total | |||||||||||
|  27 Oct 2006, 10:45 | 
 | 
| Goplat 27 Oct 2006, 17:28 Madis: That will be wrong when N is even. It's supposed to be ((1+N)*N) shr 1. | |||
|  27 Oct 2006, 17:28 | 
 | 
| rhyno_dagreat 28 Oct 2006, 03:39 Ah... Well that's where the problem lies as in I don't know how to change multidigit numbers into ascii and vice versa.    | |||
|  28 Oct 2006, 03:39 | 
 | 
| rhyno_dagreat 28 Oct 2006, 19:39 Thanks! I'll try that. | |||
|  28 Oct 2006, 19:39 | 
 | 
| < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.