printf is part of the standard 'C' library and, therefore, is provided by your Compiler - so you need to read your specific Compiler Manual to determine what options it supports, and how to enable things like floating point. You still haven't said what compiler you are using.
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
I searched the net and there is no example of it being used in C. I saw an example using assembly language. If this is the case, is there a way to use float for display and computation?
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
You seem to be assuming that _dflt will change the type of the variable; but it won't - that's not how 'C' works!_dflt is a function that will return a float value - the input parameter is not affected!
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Keil supports floating point, not sure if is part of the MICROLIB, but it is working by default, and I'm doing a whole lot of trig and transcendental work.
Why wouldn't you just use casting? Not that it would provide any useful information as you have no fractional data. printf(''TimeVar of timedisplay =%d'',TimeVar); printf(''\nTimeVar in float=%f'',(float)TimeVar); printf(''\nTimeVar in double=%lf'',(double)TimeVar); So why exactly do you need floating point to compute the Julian date? If you need the time-of-day you can easily separate that from the seconds to get an integer day number. Pretty common formula I've used in the past. Googling some of the constants. http://mth.uct.ac.za/~lab/chap1/chap1.pdf Page 7 1.3.2 Given the year, month and day of the month, the Julian day is calculated as follows: Julian = (36525*year)/100 + (306001*(month+1))/10000 + day + 1720981 where month is 13 for Jan, 14 for Feb, 3 for Mar, 4 for Apr etc. For Jan and Feb, the year is reduced by 1. Write a script which asks for the day, month and year and calculates the Julian day. All variables must be of integer type. What is the Julian day for 7 Jun 2008? [The answer is 2454624]. In C int ComputeJulian(int Day, int Month, int Year) { int JulianDate; // Month 1-12 // Year 1901-2099, evaluated if (Month <= 2) { Year--; Month += 12; } JulianDate = (36525 * Year) / 100 + (306001 * (Month + 1)) / 10000 + Day + 1720981; return(JulianDate); }
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
I think you need to spend some time with a 'C' textbook to gain a proper understanding of the 'C' programming language.
int int_variable = 23; // Define a variable of type 'int',
// and initialise it with the value 23
double double_variable; // Define a variable of type 'double',
// the value is not initialised.
// Call the function '_dflt' to read the 'int' value from 'int_variable',
// and return the corresponding 'double' value, assigning it to 'double_variable'
double_variable = _dflt( int_variable );
// at this point, 'double_variable' now contains the 'double' value corresponding // to the 'int' value stored in 'int_variable'; // The type and value of 'int_variable' are unchanged. This is basic 'C' language stuff - nothing specifically to do with Keil or STM32.
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
''Apparently you haven't used some of the ST example code with Keil, as 512 bytes of stack is inadequate.''
Correct, I haven't. ''It has nothing to do with the firmware library! printf is part of the standard 'C' library and, therefore..'' Probably, but some chip vendors include their own printf function which will over-ride the compilers library version.
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
But surely the fraction portion represents a fixed period of 24 hours, to some arbitrary precision, aligned to some timezone. I've used a variation of this algorithm to compute GPS Week Numbers, and carry the Time-Of-Week to 10's of nanoseconds.
Window's FILETIME is a 64-bit integer representation of 100ns ticks since 1601, and NTP uses a 64-bit (32.32) fixed point representation to some picosecond resolution. Either would be superior to a floating point time line. Printing the fractional portion of the NTP time is quite easy with integer math. I have both implemented on my STM32.
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..