Go to Post Warning: My opinion is worthless at inspection. - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-02-2006, 16:02
Max Brin Max Brin is offline
Registered User
FRC #1943 (Neat Team)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Israel
Posts: 52
Max Brin has a spectacular aura aboutMax Brin has a spectacular aura aboutMax Brin has a spectacular aura about
Very wierd compiling problem!

Hey,

I've tried to make a very simple statment:


Code:
float test = 3.14;

            printf("%f", test);
it wont print anything.. what seems to be the problem?

Thanks.
  #2   Spotlight this post!  
Unread 07-02-2006, 16:21
Eldarion's Avatar
Eldarion Eldarion is offline
Electrical Engineer / Computer Geek
AKA: Eldarion Telcontar
no team (Teamless Orphan)
Team Role: Alumni
 
Join Date: Nov 2005
Rookie Year: 2005
Location: Númenor
Posts: 558
Eldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond repute
Send a message via AIM to Eldarion Send a message via Yahoo to Eldarion
Re: Very wierd compiling problem!

Quote:
Originally Posted by Max Brin
Hey,

I've tried to make a very simple statment:


Code:
float test = 3.14;

            printf("%f", test);
it wont print anything.. what seems to be the problem?

Thanks.
I don't think the RC supports printf with a float modifier. Try %d with an integer value and see what happens.
__________________
CMUCam not working? Tracks sporadically? Try this instead: http://www.falconir.com!
PM me for more information if you are interested (it's open source!).

Want the FIRST Email blasts? See here: http://www.chiefdelphi.com/forums/sh...ad.php?t=50809

"The harder the conflict, the more glorious the triumph. What we obtain too cheaply, we esteem too lightly; it is dearness only that gives everything its value."
-- Thomas Paine

If it's falling apart it's a mechanical problem. If it's spewing smoke it's a electrical problem.
If it's rampaging around destroying things it's a programming problem.

"All technology is run on 'Magic Smoke' contained within the device. As everyone knows, whenever the magic smoke is released, the device ceases to function."
-- Anonymous

I currently speak: English, some German, Verilog, x86 and 8051 Assembler, C, C++, VB, VB.NET, ASP, PHP, HTML, UNIX and SQL
  #3   Spotlight this post!  
Unread 07-02-2006, 16:21
Alan Anderson's Avatar
Alan Anderson Alan Anderson is online now
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Very wierd compiling problem!

So far as I can tell, with the C18 compiler we use,

1) strings to be printf'd need a terminating \r

and

2) %f is not supported.
  #4   Spotlight this post!  
Unread 08-02-2006, 07:06
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Very wierd compiling problem!

Quote:
Originally Posted by Alan Anderson
So far as I can tell, with the C18 compiler we use,

1) strings to be printf'd need a terminating \r
It appears to be possible (at least for us) to have a printf without a terminating \r, as long as you get a \r in before the buffer is flushed. (presumably at the end of the loop)
__________________

  #5   Spotlight this post!  
Unread 08-02-2006, 12:41
pclements's Avatar
pclements pclements is offline
Registered User
AKA: Patrick
FRC #1254 (Entropy)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Lawrence
Posts: 18
pclements is an unknown quantity at this point
Send a message via Yahoo to pclements
Re: Very wierd compiling problem!

Quote:
Originally Posted by Max Brin
Hey,

I've tried to make a very simple statment:


Code:
float test = 3.14;

            printf("%f", test);
it wont print anything.. what seems to be the problem?

Thanks.
try using an intereger instead of a float, or even a char which will do the same thing a float does. a printable float is not compatable with the Ccompilers.
__________________
Does the walker choose the path, or the path the walker?" -- Garth Nix
  #6   Spotlight this post!  
Unread 08-02-2006, 13:03
aaeamdar's Avatar
aaeamdar aaeamdar is offline
Post-A-Holic
AKA: Paul Dennis
FRC #1719 (The Umbrella Corp)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Baltimore, MD
Posts: 231
aaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant future
Re: Very wierd compiling problem!

2 things:

To be technical, your error (as you've explained it) is run-time, not compile-time error. A run-time error is something odd that happens during the execution of the code that you didn't expect. It may be a crash or just may not print what you thought it would.

The other "thing" is this: when do you need to print out floats? I dunno, maybe you do need them. Important values like motors are unsigned chars, however. Most of what you're working with is bits and chars. If you really need this to work, it's worth your time; otherwise, there are probably 400 better things to do.

Best of luck with it...

Paul dennis
  #7   Spotlight this post!  
Unread 08-02-2006, 15:43
steven114 steven114 is offline
Programming Wizard and Team Captain
AKA: Steven Schlansker
FRC #0114 (Eaglestrike)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Los Altos, CA
Posts: 335
steven114 is a jewel in the roughsteven114 is a jewel in the roughsteven114 is a jewel in the rough
Send a message via AIM to steven114
Re: Very wierd compiling problem!

If you absolutely must print out a float,do this: print the integer part, then take the remaining decimal part, multiply by some power of ten (say, 1000) and print out this number after a decimal point.
__________________
Shift to the left, shift to the right!
Pop up, push down, byte, byte, byte!
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a realistic Statics Problem sanddrag Technical Discussion 10 05-12-2005 15:07
Programming Problem: Extremely Frustrating chantilly_team Programming 19 12-02-2005 23:00
Problem compiling edubot Ben B Programming 3 14-01-2004 00:51
The problem with scouting... archiver 2001 10 23-06-2002 23:49
Major problem with chipphua motors aka Scott White Motors 18 19-03-2002 19:44


All times are GMT -5. The time now is 01:39.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi