This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Variable assignment using expression does not work...  RSS feed

 
Greenhorn
Posts: 9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My calculations are not working.  I keep getting the same results, no matter what numbers I put in to begin with.  Here's the code:



This gives me 0.0C and 273.15K every single time.

What's going on?  Thanks.
 
Rancher
Posts: 3127
110
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Thomas,

have you been told about integer division yet? Try

and notice the outcome. A simple remedy against this is for instance:
but there are other ways too.
 
Marshal
Posts: 63843
209
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I shall leave you to work out why you might also sort out that problem by removing one pair of () from each line.
 
Piet Souris
Rancher
Posts: 3127
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh, missed that. Well spotted!
 
Campbell Ritchie
Marshal
Posts: 63843
209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't do the same arithmetic twice.Try and avoid C/F: try \u2193 \u2103 or \u2109. The Kelvin symbol \u212a looks indistinguishable from an ordinary K.
 
Piet Souris
Rancher
Posts: 3127
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote: (...)Try and avoid C/F: try \u2193 \u2103 or \u2109. The Kelvin symbol \u212a looks indistinguishable from an ordinary K.


I tried to use unicode characters a while ago in my reply, but to no vail: all I got was this '\uxxxx' literally.. Is it explained somewhere how to correctly  insert these chars? Couldn't find it.
 
Campbell Ritchie
Marshal
Posts: 63843
209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The HTML combination ℃ shows up as ℃.
 
Sheriff
Posts: 24295
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:I tried to use unicode characters a while ago in my reply, but to no vail: all I got was this '\uxxxx' literally.



The Ranch uses UTF-8 as its encoding, so if you can type (or paste) a Unicode character in the reply box then that should be enough. But note that I said Unicode characters. You seem to be talking about Unicode escapes, which are only used in Java source code. Like Campbell said, if you can't type the character then HTML escapes are the way to do that. And furthermore if you want to discuss HTML escapes in the forum then you'll need to escape the & at the beginning of the HTML escape you want to discuss.
 
Thomas Mahoney
Greenhorn
Posts: 9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, guys.  Thanks for all of your help.  You really saved this program.
 
Campbell Ritchie
Marshal
Posts: 63843
209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:. . . you'll need to escape the & . . .

Do you mean like this:- & or & or && or &&&&&&&&&&&&&&&&&&&& ?
 
Piet Souris
Rancher
Posts: 3127
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Thomas
You're welcome!

@Campbell and Paul
that was still hard... what on earth is 'escaping html'?
But finally I managed, and using the 'x' that I constantly overlooked helped as well! Indeed, me dummy, and for dummies like me: to get that Celsius symbol I had to type "& #x2103" (without the space), and to get "&#x2103" I had to type "& amp#x2103" (again without the space).

Thank you, guys!
 
Campbell Ritchie
Marshal
Posts: 63843
209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:. . . & amp#x2103 . . .

Full instructions in my previous post. Remember it's &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
 
Campbell Ritchie
Marshal
Posts: 63843
209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:. . . & amp#x2103 . . .

&‍amp;#x2103;

And I'm not saying how I got rid of the space!
 
Piet Souris
Rancher
Posts: 3127
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm...   hopefully that doesn't spoil my well deserved nightrest.
 
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!