Write your own math program for FreeDOS

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ธ.ค. 2024

ความคิดเห็น • 30

  • @ahmad-murery
    @ahmad-murery ปีที่แล้ว +2

    It's always a happy day when it starts with a retro programming session, it makes me think simpler and relaxes my brain muscles.
    Thanks Jim,

  • @sharoyveduchi
    @sharoyveduchi ปีที่แล้ว +12

    It's unfortunate there are audio issues (brief moments where audio gets cut off) but this video was very informative. Thank you. I'm tempted to write my own.

    • @ahmad-murery
      @ahmad-murery ปีที่แล้ว

      I thought the audio issue is just on my side (my ears in particular)

    • @freedosproject
      @freedosproject  ปีที่แล้ว +4

      It's not you. I had this comment in the video description: "Apologies for the sound issues on this one. I recorded it immediately after last week's video, and I didn't realize my sound setup was causing issues. I'll fix it for the next video"

    • @freedosproject
      @freedosproject  ปีที่แล้ว +2

      Yes, I think I had a video meeting app running in the background (not in a meeting, but the client was idle) and it was fighting for the mic. At least, that's what I suspect happened. I'll make sure the next video has better sound.

  • @OpenGL4ever
    @OpenGL4ever ปีที่แล้ว +3

    Even when atof does transform a string into the value 0 dot 0 you should check if the string given is a number with isdigit from ctype header.

    • @freedosproject
      @freedosproject  ปีที่แล้ว +1

      That would be a good addition, especially to warn the user if they wrote "q13 + 12" (such as a typo)

  • @Flora-ng8gt
    @Flora-ng8gt ปีที่แล้ว +1

    ❤Freedos The best Power
    System❤Brazil❤

  • @joeshmoe000
    @joeshmoe000 ปีที่แล้ว +1

    I'm wondering if the data type on a separate line before function name is just old convention or if this compiler needs that?

    • @freedosproject
      @freedosproject  ปีที่แล้ว +2

      You mean the "int" on a separate line from "main(int argc, char **argv)" ? That's coding style preference. I learned it that way, when I first learned C, and it sort of stuck with me. You could also write it as "int main(int argc, char **argv)" and that would be fine too.

    • @joeshmoe000
      @joeshmoe000 ปีที่แล้ว

      ​@@freedosproject Yes, that's what I meant. I see you did that with all your functions. That's what I like about C; it's flexible.

  • @DV-ye6xb
    @DV-ye6xb ปีที่แล้ว +1

    Hey i wrote this program to practice c the program tells a person how many boxes he can buy depending how much money the person has what do you think is there anything that can make this code better?
    #define BOX 6
    Int main() {
    double dollars;
    double cost;
    printf("a box is $6 how many dollars do you have? ");
    scanf("%lf", dollars);
    cost = dollars / BOX;
    printf("you can buy %lf boxes", cost);
    return 0;
    }

    • @freedosproject
      @freedosproject  ปีที่แล้ว +1

      When dealing with monetary values, float is fine; you don't need double.
      Also, you define BOX as 6 but don't use it in your first printf. You could write:
      printf("a box is worth $%f ...
      ", BOX);
      But note that BOX is meant to be a dollar value, so you probably want to define this as 6.00 so it's a float value.
      Also, boxes come in integer values, because that's a count. So you should be careful to only report an int value. One way to do this is by declaring:
      int count;
      Then:
      count = (int) ( dollars / box );
      printf("you can buy %d boxes
      ", count);
      The (int) isn't strictly necessary here, since C will make the final value an int when it saves the result in count.

    • @DV-ye6xb
      @DV-ye6xb ปีที่แล้ว

      @@freedosproject ok thank you.

  • @OpenGL4ever
    @OpenGL4ever ปีที่แล้ว +1

    Why don't you use the *default* clause inside the switch statement for the unrecongnized operation? I would assume, that the compiler can optimize it better, when you use a default clause, instead of writing the default message outside of the switch statement.

    • @freedosproject
      @freedosproject  ปีที่แล้ว +1

      I haven't tested optimization with/without "default" for this example. However, I can say that GCC will complain when compiling this program and you use "default" instead of letting the "switch" exit. So I avoided the compiler warning in this example.

  • @SlideRSB
    @SlideRSB ปีที่แล้ว +1

    Instead of returning 0 for invalid operations and division by zero, wouldn't it be more appropriate to return NaN?

    • @freedosproject
      @freedosproject  ปีที่แล้ว +2

      Good question! I didn't use "NAN" for two reasons:
      1. NAN may or may not be defined, and "is defined if and only if the implementation supports quiet NaNs for the float type. It expands to a constant expression of type float representing a quiet NaN."
      But more importantly:
      2. This was a quick math program, and there wasn't a need to return NAN. The program just does one operation and quits, so returning NAN doesn't really add value here. (And it prints an error anyway.)

    • @SlideRSB
      @SlideRSB ปีที่แล้ว

      @@freedosproject Thanks for the explanation. I had to look up quiet NaN since that's a term I'm not familiar with. I think a video explaining quiet NaN and signalling NaN would help for me to understand the concept better.

  • @ernietech-101
    @ernietech-101 ปีที่แล้ว +1

    Someday I'll buckle down and learn C++. Someday..........

    • @OpenGL4ever
      @OpenGL4ever ปีที่แล้ว

      This isn't C++, it's C.

    • @freedosproject
      @freedosproject  ปีที่แล้ว

      I assume you meant C ☺
      I find C is pretty easy to learn. It has very few keywords, so it's fast to pick up. I taught myself C in college by reading a book.

  • @davemurey6119
    @davemurey6119 ปีที่แล้ว +1

    Очень хороший бесплатный компилятор - Free Pascal, имеет мощную IDE. Зачем этот C? Только если вы предпочитаете этот язык?

    • @freedosproject
      @freedosproject  ปีที่แล้ว

      I prefer C programming on DOS. It's what I know best. I'm not a Pascal programmer.

  • @joeshmoe000
    @joeshmoe000 ปีที่แล้ว

    If I ever get rich, I'm giving you 500K to make a modern DOS 64-bit, VESA graphics, Gigs of RAM, built in networking, no extenders, etc. I know, i know, here I am again. I'm telling you, there's a huge hole in the market for a debloated, stable, simple OS that works like DOS. Imagine banking systems, military, etc. Do they want to use windows? Probably not. Forced updates, instability, copious background processes constantly accessing the disk, so a power outage could result in corruption. Then there's Linux/Unix which is too complex and convoluted. Seeing hi-res text mode apps would be beautiful. It'd be like what we thought the future would look like in the 80s.
    I wish I was a smarter programmer, cause I would make it. I was stuck with real mode back when I tried to make my own OS. If you think it's a decent idea, you could let other programming friends know.

    • @eternaldoorman5228
      @eternaldoorman5228 ปีที่แล้ว

      As a programmer who worken on DOS in the eighties for companies whoch included IBM, I can tell you that you don't need DOS for what you want to do. DOS was more of a hindrance than a help most of the time. It was just a rip-off of CP/M written in a hotel room by a Harvard dropout so could get a sweet deal through his daddy, and that's what the great US siftware industry was launched off. Makes Elon Musk's spaceport launchpads look like good engineering.

  • @philtoa334
    @philtoa334 ปีที่แล้ว +1