17 June 2018, 00:44 | #1 |
Registered User
Join Date: Mar 2018
Location: Paderborn/Germany
Posts: 19
|
Learning how to Code: Question!
Hello I have written a small Addition Program for Amiga Computers.. I managed that it runs with Integer but I don't know how to manage float Operations with vbcc!
This Code works: Code:
#include <stdio.h> int main(void) { int a; int b; int res; printf("\\n\\nWelcome to Amiga Micro Add V.0.0.1\\n\\\n"); printf("\\nPlease enter a Number for Addition : "); scanf("%d",&a); printf("\\nPlease enter a second Number for Addition: "); scanf("%d",&b); res = a + b; printf("\\nThe result is: %d\\n", res); return 0; } Code:
#include <stdio.h> #include <stdlib.h> int main(void) { float a; float b; float res; printf("\\n\\nWelcome to Amiga Micro Add V.0.0.2\\n\\n"); printf("\\nPlease enter a Number for Addition : "); scanf("%f",&a); printf("\\nPlease enter a second Number for Addition: "); scanf("%f",&b); res = a + b; printf("\\nThe result is: %f\\n", res); return 0; } I did it with WinUAE configured with a 68040 CPU! |
17 June 2018, 01:04 | #2 |
Registered User
Join Date: Mar 2018
Location: Paderborn/Germany
Posts: 19
|
Solved!
Both Codes are correct! I found the Error you have to compile with the -lmieee Option Compile Command: vc -o microadd.exe microadd.c -lmieee then it works! |
18 June 2018, 12:22 | #3 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,502
|
Explanation: The standard clib (vc.lib) does not include floating point support to keep programs small. When linking with the mlib (mieee.lib for soft-float) several functions (like printf, scanf, etc.) are replaced by extended versions with floating point included.
|
18 June 2018, 13:07 | #4 |
Registered User
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 41
Posts: 3,773
|
QBit: Can you please post the file sizes of both executables? I'm interested to see how much -lmieee increases the file size.
|
18 June 2018, 21:18 | #5 |
Registered User
Join Date: Mar 2018
Location: Paderborn/Germany
Posts: 19
|
Hewitson, the Integer version without -lmieee has 12.876 bytes as exe,, and the float with -lmieee Option has 18.780 bytes! Quite big Monsters of Programms! *lol*
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Epic: Is the sound code broken after a while? + question about the music + HOL cheat | lilalurl | support.Games | 6 | 26 May 2019 21:32 |
Learning C | nobody | Coders. C/C++ | 28 | 15 June 2016 08:07 |
Wanting to start learning to code amiga in asm | fishyfish | Coders. Asm / Hardware | 5 | 03 March 2012 06:11 |
Suggestions for learning | pmc | Coders. Tutorials | 248 | 20 October 2010 21:42 |
A question for those of you who can look into a games code. | Ironclaw | Retrogaming General Discussion | 22 | 28 January 2005 22:00 |
|
|