0

I've set up firms (turtles) in an industry (world) which either produce at home (firms-at-home located > ycor) or have offshored their production (offshore-firms located < ycor). I have given them a firms-own called offshored? which is answered with either true or false.

I have a monitor on my interface which shows the amount of firms which have offshored and the ones which produce at home (in %) of all firms in the setup-world:

breed [ firms firm ]

firms-own [
  offshored?   ;; true or false
]

to-report percentage-of-firms-at-home   ;; monitors the % of firms which produce at home
  report ( ( count firms with [ ycor > 0 ] ) / count firms ) * 100
end

to-report percentage-of-offshored-firms   ;; monitors the % of offshored firms
  report ( ( count firms with [ ycor < 0 ] ) / count firms ) * 100
end

I then plugged percentage-of-offshored-firms into a monitor on the interface. Now, I would like to have an absolute number show up for my reported percentage. How can I change the decimal number I receive so far to an absolute one?

user11277648
  • 53
  • 1
  • 5
  • 1
    What exactly do you mean with "absolute number"? For absolute value, you can use `abs percentage-of-offshored-firms` but this doesn´t make much sense since the percentage never will be negative. You probably mean, that you want to cut off digits. Than use `precision percentage-of-offshored-firms 0` to have no digits. – geruter Apr 19 '19 at 13:16
  • This was exactly what I was after! Thank you. – user11277648 Apr 20 '19 at 14:09
  • What if I calculate a specific value within my code and have it report as a turtles-own. Is there a way to let NetLogo know that it needs to round the number down? My example here is employment which is calculated with ```set employment-at-home labour-costs / wages-at-home ]```. Obviously, I can't have 1.2 workers employed-at-home but it needs to be a whole value. Is that possible? – user11277648 Apr 20 '19 at 14:12
  • 1
    If you want to round down to the next integer, use `floor` .To round up, use `ceiling`. For true rounding, use `round`. Marking the command and pressing F1 takes you to the documentation for more info. – geruter Apr 22 '19 at 12:29
  • Thanks a lot! I found the NetLogo dictionary for more info. – user11277648 Apr 23 '19 at 10:41
  • Sure, no problem! – geruter Apr 25 '19 at 14:07

0 Answers0